How to use the most.combine function in most

To help you get started, we’ve selected a few most 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 izaakschroeder / afflux / lib / observe.js View on Github external
constructor(props, context) {
				super(props, context);

				const observables = get(context.stores);
				// Create a combined stream that maps all the observables to a
				// single state value for the react component.
				this.property = combine(state, observables);
			}
github mostjs / core / examples / add-inputs / main.js View on Github external
exports.main = function() {
	// x represents the current value of xInput
	var x = most.fromEvent('input', xInput).map(toNumber);

	// x represents the current value of yInput
	var y = most.fromEvent('input', yInput).map(toNumber);

	// result is the live current value of adding x and y
	var result = most.combine(add, x, y);

	// Observe the result value by rendering it to the resultNode
	result.observe(renderResult);
};
github fiatjaf / stack-forum / client / app.js View on Github external
// array of threads
      for (let i = 0; i < cur.length; i++) {
        let thread = map[cur.id] || {id: cur.id}
        for (let k in cur[i]) {
          thread[k] = cur[i][k]
        }
        map[cur[i].id] = thread
      }
    } else {
      // single thread
      map[cur.id] = cur
    }
    return map
  }, {})

  let vtree$ = most.combine(({value}, threads, storage) =>
    h('div', [
      vrender.nav(),
      fwitch(value.where, {
        'THREADS': () => vrender.list({threads}, storage['typed.']),
        'THREAD': () =>
          threads[value.id]
            ? vrender.standalone(threads[value.id], storage[`typed.${value.id}`])
            : vrender.empty()
      })
    ])
  ,
    match$,
    threadMap$,
    STORAGE.all$
  )
    .map(x => x || vrender.empty())
github goodmind / cycle-telegram / test / integration / index / most.ts View on Github external
bot: most.from([
      most.of(sendGame(
        { chat_id: GROUP_ID,
          game_short_name: 'test' },
        {})),

      bot.events('message')
        .map(x => x.message.from)
        .tap(() => bot.dispose())
        .combine((user, message) => ({ message, user }), bot.responses.take(1))
        .map(({ message, user }) =>
          getGameHighScores(
            { user_id: user.id, message_id: message.message_id },
            { message })),

      most.combine(
        ([message, user], score) => ({ message, user, score }),
        bot.responses
          .take(1)
          .combine(
            (message, user) => [message, user],
            bot.events('message').tap(() => bot.dispose()).map(x => x.message.from)),
        bot.responses
          .skip(1)
          .filter(Array.isArray)
          .flatMap(most.from))
        .filter(({user, score}) => user.id === score.user.id)
        .map(({ score: { score }, user, message }) =>
          setGameScore(
            { score: score + 1, user_id: user.id, message_id: message.message_id },
            { message })),
github fanduel-oss / refract / examples / visit-time / most / src / index.js View on Github external
const aperture = () => {
    const visible$ = fromEvent('visibilitychange', document)
        .map(isVisible)
        .startWith(isVisible())
    const online$ = merge(
        fromEvent('online', window).map(() => true),
        fromEvent('offline', window).map(() => false)
    ).startWith(isOnline())

    return combine((online, visible) => online && visible, online$, visible$)
        .skipRepeats()
        .map(
            onlineAndVisible =>
                onlineAndVisible
                    ? periodic(10)
                          .map(() => ({
                              type: 'TICK'
                          }))
                          .startWith({ type: 'RESUME' })
                    : MostOf({ type: 'PAUSE' })
        )
        .switchLatest()
}
github langhuihui / rx4rx / perf / dataflow.js View on Github external
.add('most', function (deferred) {
        var source = most.from(a);
        var inc = source.filter(isPositive).map(returnPlus1);
        var dec = source.filter(isNegative).map(returnMinus1);
        var count = most.merge(inc, dec).scan(addXY, 0);
        var label = most.from(['initial', 'Count is ']);
        var view = most.combine(renderWithArgs, label, count);
        runners.runMost(deferred, view.drain());
    }, options)
    .add('rx 6', function (deferred) {
github beyond-labs / react-mirror / index.js View on Github external
});
            return { $state: $state, $props: $props };
          },
          metadata: {
            instance: _this
          }
        }),
            id = _MirrorBackend$addSto.id,
            path = _MirrorBackend$addSto.path,
            mirror = _MirrorBackend$addSto.mirror,
            dispatch = _MirrorBackend$addSto.dispatch,
            streams = _MirrorBackend$addSto.streams;

        Object.assign(_this, { id: id, depth: path.length, mirror: mirror, dispatch: dispatch });

        var $propsState = streams.$state ? most.combine(instantiseMapToProps(mapToProps.bind(_this)), streams.$state, streams.$props) : streams.$props.map(instantiseMapToProps(mapToProps.bind(_this, undefined)));

        $propsState.skipRepeatsWith(pure.propsStateEqual.bind(_this)).thru(scheduler.addStream.bind(null, _this.depth, id)).observe(function (propsState) {
          _this._propsState = propsState;
          if (_this._unmounted) return;
          _this.setState(function (_ref2) {
            var updateCount = _ref2.updateCount;
            return {
              updateCount: updateCount + 1,
              propsState: propsState
            };
          });
        }).then(scheduler.removeStream.bind(null, id));
        return _this;
      }
github staltz / xstream / perf / dataflow.js View on Github external
.add('most', function (deferred) {
    var source = most.from(a);
    var inc = source.filter(isPositive).map(returnPlus1);
    var dec = source.filter(isNegative).map(returnMinus1);
    var count = most.merge(inc, dec).scan(addXY, 0);
    var label = most.from(['initial', 'Count is ']);
    var view = most.combine(renderWithArgs, label, count);
    runners.runMost(deferred, view.drain());
  }, options)
  .add('rx 5', function (deferred) {
github motorcyclejs / motorcyclejs / dom / src / vTreeParser.js View on Github external
vTree => {
    if (!vTree) {
      return null
    } else if (vTree.observe) {
      return vTree.map(vTreeParser).switch()
    } else if (`object` === typeof vTree) {
      const vTree$ = most.just(vTree)
      if (vTree.children && vTree.children.length > 0) {
        return most.combine(
          combineVTreeStreams,
          vTree$,
          ...filter(
            map(vTree.children, vTreeParser),
            x => x !== null
          )
        )
      }
      return vTree$
    } else {
      throw new Error(`Unhandled tree value`)
    }
  }
github beyond-labs / react-mirror / src / bindings / react.js View on Github external
if (!state || !$state || !$state.subscribe) return { $props };
              $state = $state
                .skipRepeatsWith(pure.stateEqual.bind(this))
                .filter(state => state !== undefined)
                .tap(state => (this._state = state));
              return { $state, $props };
            },
            metadata: {
              instance: this
            }
          }
        );
        Object.assign(this, { id, depth: path.length, mirror, dispatch });

        const $propsState = streams.$state
          ? most.combine(
              instantiseMapToProps(mapToProps.bind(this)),
              streams.$state,
              streams.$props
            )
          : streams.$props.map(
              instantiseMapToProps(mapToProps.bind(this, undefined))
            );

        $propsState
          .skipRepeatsWith(pure.propsStateEqual.bind(this))
          .thru(scheduler.addStream.bind(null, this.depth, id))
          .observe(propsState => {
            this._propsState = propsState;
            if (this._unmounted) return;
            this.setState(({ updateCount }) => ({
              updateCount: updateCount + 1,