transferum
    Preparing search index...

    Function createStoredChannelTransfer

    • Creates a StoredChannelTransfer — a channel that stores the last value with external management.

      Capabilities: Pullable, Subscribable, Triggerable

      Type Parameters

      • T

      Parameters

      Returns ExplicitTransfer<T, T>

      const channel = createStoredChannelTransfer<number>({
      setup: (emit) => {
      const ws = new WebSocket('ws://example.com');
      ws.onmessage = (e) => emit(JSON.parse(e.data));
      },
      destroy: () => ws.close()
      });
      console.log(channel.pull()); // last value
      channel.subscribe(x => console.log(x));