empty
値を持たず、作られた時点で完了している Observable を作成します(RxJS の EMPTY とほぼ同等)。何も流さないので、switchMap で何も追わない側の分岐に有用です。source() を使うと、誰も呼ばない next を持つものになってしまいます。
import { createState, empty, switchMap } from 'synstate';
const [isFollowing$, setIsFollowing] = createState(true);
const [count$, setCount] = createState(0);
// isFollowing$ が false の間は、count$ の値を何も流さないconst followed$ = isFollowing$.pipe( switchMap((isFollowing) => (isFollowing ? count$ : empty<number>())),);