@thi.ng/rstream
Version:
Reactive streams & subscription primitives for constructing dataflow graphs / pipelines
28 lines • 719 B
TypeScript
import type { CommonOpts } from "./api.js";
import { Subscription } from "./subscription.js";
/**
* Returns a {@link Subscription} which toggles between true/false for each
* {@link Subscription.next} call. The sub will be seeded with the given
* `initial` value.
*
* @example
* ```ts tangle:../export/toggle.ts
* import { toggle, trace } from "@thi.ng/rstream";
*
* const mute = toggle(false);
*
* mute.subscribe(trace("mute"));
* // mute false
*
* mute.next();
* // mute true
*
* mute.next();
* // mute false
* ```
*
* @param initial
* @param opts
*/
export declare function toggle(initial: boolean, opts?: Partial<CommonOpts>): Subscription<void, boolean>;
//# sourceMappingURL=toggle.d.ts.map