Mirror: 馃帺 A tiny but capable push & pull stream library for TypeScript and Flow
1import { TalkbackFn, TeardownFn, Start, Push, SignalKind } from './types'; 2 3/** Placeholder {@link TeardownFn | teardown functions} that's a no-op. 4 * @see {@link TeardownFn} for the definition and usage of teardowns. 5 * @internal 6 */ 7export const teardownPlaceholder: TeardownFn = () => { 8 /*noop*/ 9}; 10 11/** Placeholder {@link TalkbackFn | talkback function} that's a no-op. 12 * @privateRemarks 13 * This is frequently used in the codebase as a no-op initializer value for talkback functions in 14 * the implementation of {@link Operator | Operators}. This is cheaper than initializing the 15 * variables of talkbacks to `undefined` or `null` and performing an extra check before calling 16 * them. Since the {@link Start | Start signal} is assumed to come first and carry a talkback, we can 17 * use this to our advantage and use a no-op placeholder before {@link Start} is received. 18 * 19 * @internal 20 */ 21export const talkbackPlaceholder: TalkbackFn = teardownPlaceholder; 22 23/** Wraps the passed {@link TalkbackFn | talkback function} in a {@link Start | Start signal}. 24 * @internal 25 */ 26export function start<T>(talkback: TalkbackFn): Start<T> { 27 const box: any = [talkback]; 28 box.tag = SignalKind.Start; 29 return box; 30} 31 32/** Wraps the passed value in a {@link Push | Push signal}. 33 * @internal 34 */ 35export function push<T>(value: T): Push<T> { 36 const box: any = [value]; 37 box.tag = SignalKind.Push; 38 return box; 39}