How to use the xstream.from function in xstream

To help you get started, we’ve selected a few xstream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / xstream_v7.x.x / test_xstream.js View on Github external
const producer = {
  start: (listener) => {
    listener.next(1);
    listener.next(2);
    listener.next(3);
    listener.complete();
  },
  stop: console.log
};

const create: Stream = xs.create(producer);
const createWithMemory: MemoryStream = xs.createWithMemory(producer);
const never: Stream<*> = xs.never();
const empty: Stream<*> = xs.empty();
const _throw: Stream<*> = xs.throw(new Error(123));
const from1: Stream = xs.from([1]);
const from2: Stream = xs.from(Promise.resolve(1));
const of: Stream = xs.of(1);
const fromArray: Stream = xs.fromArray([1,2,3]);
const fromPromise: Stream = xs.from(Promise.resolve(1));
const periodic: Stream = xs.periodic(123);
const merge: Stream = xs.merge(of, of);
const merge2: Stream = xs.merge(of, of, of, of);
const combine: Stream = xs.combine(of, of);
const combine2: Stream = xs.combine(of, of, of, of);

const listener = {
  next: console.log,
  error: console.error,
  complete: console.log
};
github goodmind / cycle-telegram / test / integration / index / xstream.ts View on Github external
let main = () => ({
    bot: xs.from([
      xs.of(getUserProfilePhotos(
        { user_id: 39759851 },
        {}))
    ])
  })
  let { sources, run } = Cycle(main, { bot: basicDriver })
github aronallen / cycle-sandbox / src / main.ts View on Github external
return isolate((sources) => {
        const sinks$ = xs.from(sandbox(resource, sources, connectors));
        return expectedSinks.reduce((acc, key) => ({
          ...acc,
          [key]: adapt(sinks$.debug('sinks').map((sinks) => xs.from(sinks[key])).flatten())
        }), {});
      })(sources);
    }
github aronallen / cycle-sandbox / src / sandbox.ts View on Github external
return isolate((sources) => {
      const sinks$ = xs.from(sandbox(resource, sources, bridges));
      return expectedSinks.reduce((acc, key) => ({
        ...acc,
        [key] : adapt(sinks$.debug('sinks').map((sinks) => xs.from(sinks[key])).flatten())
      }), {});
    })(sources);
}
github aronallen / cycle-sandbox / src / main.ts View on Github external
          [key]: adapt(sinks$.debug('sinks').map((sinks) => xs.from(sinks[key])).flatten())
        }), {});
github aronallen / cycle-sandbox / src / sandbox.ts View on Github external
        [key] : adapt(sinks$.debug('sinks').map((sinks) => xs.from(sinks[key])).flatten())
      }), {});
github fanduel-oss / refract / base / redux / observable_xstream.ts View on Github external
return xs.create({
                start(listener: Partial>) {
                    unsubscribe = store.addActionListener(
                        actionOrSelector,
                        listener.next.bind(listener)
                    )
                },

                stop() {
                    unsubscribe()
                }
            })
        }

        if (typeof actionOrSelector === 'function') {
            return xs
                .from(store)
                .map(actionOrSelector)
                .compose(dropRepeats())
        }
    }
}
github aronallen / cycle-sandbox / src / sandbox.ts View on Github external
next (message) {
            if (message.cmd === WorkerDOMMessageCommand.vnode) {
              const vnode = message.payload as VNode;
              observer.next(vnode);
            } else if (message.cmd === WorkerDOMMessageCommand.attach) {
              const payload = message.payload as WorkerDOMAttachMessage;
              const options = payload.options || {};
              attachments[payload.listenerId] = (xs.from(source
                .select(payload.selector)
                .events(payload.events, options.useCapture)) as FantasyObservable)
                .subscribe({
                  next (event: Event) {
                    if (options.preventDefault) {
                      event.preventDefault();
                    }
                    if (options.stopPropegation) {
                      event.stopPropagation();
                    }
                    tx.postMessage(
                      synthesizeEvent(event, payload.listenerId)
                    )
                  },
                  error (e) {