How to use the rx.Observable.from function in rx

To help you get started, we’ve selected a few rx 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 huluoyang / freecodecamp.cn / server / boot / challenge.js View on Github external
.flatMap(block => {
              // find where our challenge lies in the block
              const challengeIndex$ = Observable.from(
                block.challenges,
                null,
                null,
                Scheduler.default
              )
                .findIndex(({ id }) => id === challengeId);

              // grab next challenge in this block
              return challengeIndex$
                .map(index => {
                  return block.challenges[index + 1];
                })
                .flatMap(nextChallenge => {
                  if (!nextChallenge) {
                    return firstChallengeOfNextBlock$;
                  }
github TylorS / cycle-snabbdom / test / browser / dom-driver.js View on Github external
it('should not work after has been disposed', function (done) {
    const number$ = Observable.from([1, 2, 3])
      .concatMap(x => Observable.of(x).delay(50))

    function app () {
      return {
        DOM: number$.map(number =>
            h3('.target', String(number))
        )
      }
    }

    const {sinks, sources} = Cycle.run(app, {
      DOM: makeDOMDriver(createRenderTarget())
    })

    sources.DOM.select(':root').elements.skip(1).subscribe(function (root) {
      const selectEl = root.querySelector('.target')
github freeCodeCamp / freeCodeCamp / test-challenges.js View on Github external
.flatMap(challengeSpec => {
    return Observable.from(challengeSpec.challenges);
  })
  .filter(({ challengeType }) => challengeType !== modern)
github goodmind / cycle-telegram / test / integration / index / rx.ts View on Github external
let main = ({ bot }: Sources) => ({
    bot: $.from([
      bot.events('inline_query')
        .do(() => bot.dispose())
        .map(answerInlineQuery(results))
    ])
  })
  let { sources, run } = Cycle(main, { bot: basicDriver })
github freeCodeCamp / freeCodeCamp / server / middlewares / migrate-completed-challenges.js View on Github external
function buildChallengeMap(userId, completedChallenges = [], User) {
  return Observable.from(
    completedChallenges,
    null,
    null,
    Scheduler.default
  )
    .map(challenge => {
      return challenge && typeof challenge.toJSON === 'function' ?
        challenge.toJSON() :
        challenge;
    })
    .map(updateId)
    .filter(({ id, _id }) => ObjectID.isValid(id || _id))
    .map(updateName)
    .reduce((challengeMap, challenge) => {
      const id = challenge.id || challenge._id;
github electron-userland / electron-spellchecker / src / dictionary-sync.js View on Github external
preloadDictionaries(languageList=null) {
    return Observable.from(languageList || getInstalledKeyboardLanguages())
      .flatMap((x) => Observable.fromPromise(this.loadDictionaryForLanguage(x, true)))
      .reduce((acc,x) => { acc.push(x); return acc; }, [])
      .toPromise();
  }
}
github freeCodeCamp / freeCodeCamp / common / app / redux / fetch-challenges-epic.js View on Github external
.flatMap(({ entities, result, redirect } = {}) => {
          const actions = [
            fetchChallengeCompleted({
              entities,
              currentChallenge: result.challenge,
              challenge: entities.challenge[result.challenge],
              result
            }),
            redirect ? delayedRedirect(redirect) : null
          ];
          return Observable.from(actions).filter(Boolean);
        })
        .catch(createErrorObservable);
github freeCodeCamp / freeCodeCamp / common / app / utils / render-to-string.js View on Github external
export function fetch({ fetchContext = [] }) {
  if (fetchContext.length === 0) {
    log('empty fetch context found');
    return Observable.just(fetchContext);
  }
  return Observable.from(fetchContext, null, null, Scheduler.default)
    .doOnNext(({ name }) => log(`calling ${name} action creator`))
    .map(({ action, actionArgs }) => action.apply(null, actionArgs))
    .doOnNext(fetch$ => {
      if (!Observable.isObservable(fetch$)) {
        throw new Error(
          'action creator should return an observable'
        );
      }
    })
    .map(fetch$ => fetch$.doOnNext(action => log('action', action.type)))
    .mergeAll()
    .doOnCompleted(() => log('all fetch observables completed'));
}
github freeCodeCamp / freeCodeCamp / server / services / map.js View on Github external
.flatMap(challengeMap => {
      return Observable.from(Object.keys(challengeMap))
        .map(key => challengeMap[key]);
    })
    .filter(challenge => {
github tierratelematics / prettygoat / scripts / cassandra / CassandraStreamFactory.ts View on Github external
.map(buckets => {
                return Observable.from(buckets).flatMapWithMaxConcurrent(1, bucket => {
                    return mergeSort(_.map(eventsList, event => {
                        return this.client
                            .paginate(this.buildQuery(lastEvent, bucket, event), completions)
                            .map(row => this.deserializer.toEvent(row));
                    }));
                });
            })
            .concatAll();