Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "from/atom"

Index

Interfaces

Functions

Functions

Const fromAtom

  • Yields Stream of value changes in given {@link @thi.ng/atom# | Atom-like state container}.

    remarks

    Attaches a {@link @thi.ng/api#IWatch.addWatch | watch} to the atom and checks for value changes with given changed predicate (!== by default). If the predicate returns truthy result, the new value is emitted on the stream. If emitFirst is true (default), also emits atom's current value when first subscriber attaches to stream.

    Also see fromView, fromViewUnsafe

    example
    db = new Atom({ a: 23, b: 88 });
    cursor = new Cursor(db, "a")
    
    rs.fromAtom(cursor).subscribe(rs.trace("cursor val:"))
    // cursor val: 23
    
    cursor.reset(42);
    // cursor val: 42
    
    db.reset({a: 66})
    // cursor val: 66

    Type parameters

    • T

    Parameters

    • atom: ReadonlyAtom<T>

      -

    • Optional opts: Partial<FromAtomOpts<T>>

      -

    Returns Stream<T>

Generated using TypeDoc