Skip to content

fromTrigger()

Creates a manual trigger source. .fire(value) emits into the stream without equality dedup.

Signature

ts
function fromTrigger<T>(opts?: { initial?: T; name?: string }): TriggerStore<T>

Parameters

ParameterTypeDescription
opts{ initial?: T; name?: string }Optional configuration.

PropertyTypeDefaultDescription
namestringundefinedDebug name for Inspector.
initialTundefinedValue before first fire().

Returns

TriggerStore&lt;T&gt; — a store with:

MethodSignatureDescription
get()() =&gt; T \undefined
fire(value)(value: T) =&gt; voidEmit a value to all subscribers.
sourcecallbagUnderlying callbag source for subscriptions.

Basic Usage

ts
import { fromTrigger } from 'callbag-recharge/orchestrate';
import { subscribe } from 'callbag-recharge';

const trigger = fromTrigger<string>();
subscribe(trigger, v => console.log(v));
trigger.fire("go"); // logs "go"
trigger.fire("go"); // logs "go" again

Options / Behavior Details

  • No dedup: Every fire() call emits, even if the value is the same as the previous one.
  • Pulse semantics: Backed by producer() — an event source, not persistent state.

See Also

Released under the MIT License.