How to use the kefir.concat function in kefir

To help you get started, we’ve selected a few kefir 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 intraxia / wp-gistpen / commands / E2ECommand.tsx View on Github external
const startup: Delta = (action$, state$) =>
  Kefir.concat([
    // @TODO(mAAdhaTTah) use `constant` when useDelta is fixed.
    Kefir.later(0, actions.startup.request()),
    state$.take(1).flatMap(
      (state): Observable => {
        const ret = toObs(state.e2e.startup?.())
          .map(msg => actions.startup.success({ msg }))
          .flatMapErrors(err => Kefir.constant(actions.startup.failure(err)));

        return state.e2e.shutdown == null
          ? ret.takeUntilBy(action$.thru(ofType(actions.shutdown.request)))
          : ret;
      }
    )
  ]);
github intraxia / wp-gistpen / client / deltas / site.js View on Github external
        .flatMapLatest(state => Kefir.concat([
            Kefir.constant(ajaxStarted()),
            optionsAjax$(state)
                .flatMap((response: ObsResponse) => response.json())
                .map(ajaxFinished)
                .mapErrors(ajaxFailed)
        ]));
}
github intraxia / wp-gistpen / client / deltas / jobsDelta.js View on Github external
.flatMapLatest(({ route, runs, globals, jobs }: JobProps): Kefir.Observable => {
            if (typeof route.parts.run === 'string') {
                const run = runs.find((run: Run) => route.parts.run === run.ID);

                if (!run) {
                    return Kefir.never();
                }

                return Kefir.concat([
                    Kefir.constant(messagesFetchStarted()),
                    ajax$(run.console_url, {
                        method: 'GET',
                        credentials: 'include',
                        headers: {
                            'X-WP-Nonce': globals.nonce,
                            'Content-Type': 'application/json'
                        }
                    })
                        .flatMap((response: ObsResponse) => response.json())
                        .map((response: GetConsoleResponse) => messagesFetchSucceeded(response))
                        .flatMapErrors((err: TypeError) => Kefir.constant(messagesFetchFailed(err))),
                ]);
            }

            if (typeof route.parts.job === 'string') {
github intraxia / wp-gistpen / client / deltas / jobsDelta.ts View on Github external
.flatMapErrors(err => Kefir.constant(messagesFetchFailed(err))),
        ]);
      }

      if (typeof route.parts.job === 'string') {
        const job = jobs[route.parts.job];

        if (Nullable.isNone(job)) {
          return Kefir.never();
        }

        if (!jobIsSuccess(job)) {
          return Kefir.never();
        }

        const job$ = Kefir.concat([
          Kefir.constant(jobFetchStarted()),
          ajax$(job.response.rest_url, {
            method: 'GET',
            credentials: 'include',
            headers: {
              'X-WP-Nonce': globals.nonce,
              'Content-Type': 'application/json',
            },
          })
            .flatMap(response =>
              response.json().mapErrors(err => new JsonError(err)),
            )
            .flatMap(response =>
              jobResponse
                .validate(response, [])
                .fold>(
github intraxia / wp-gistpen / client / deltas / jobsDelta.js View on Github external
const job$ = Kefir.concat([
                    Kefir.constant(jobFetchStarted()),
                    ajax$(job.rest_url, {
                        method: 'GET',
                        credentials: 'include',
                        headers: {
                            'X-WP-Nonce': globals.nonce,
                            'Content-Type': 'application/json'
                        }
                    })
                        .flatMap((response: ObsResponse) => response.json())
                        .map((response: GetJobResponse) => jobFetchSucceeded(response))
                        .flatMapErrors((err: TypeError) => Kefir.constant(jobFetchFailed(err))),
                ]);

                const runs$ = Kefir.concat([
                    Kefir.constant(runsFetchStarted()),
                    ajax$(job.runs_url, {
                        method: 'GET',
                        credentials: 'include',
                        headers: {
                            'X-WP-Nonce': globals.nonce,
                            'Content-Type': 'application/json'
                        }
                    })
                        .flatMap((response: ObsResponse) => response.json())
                        .map((response: GetRunsResponse) => runsFetchSucceeded(response))
                        .flatMapErrors((err: TypeError) => Kefir.constant(runsFetchFailed(err))),
                ]);

                return Kefir.merge([job$, runs$]);
            }
github calmm-js / karet.util / src / karet.util.js View on Github external
export const serially = xs => K.concat(xs.map(toObservable))
export const parallel = xs => K.merge(xs.map(toObservable))
github intraxia / wp-gistpen / client / deltas / jobsDelta.js View on Github external
}
                    })
                        .flatMap((response: ObsResponse) => response.json())
                        .map((response: GetConsoleResponse) => messagesFetchSucceeded(response))
                        .flatMapErrors((err: TypeError) => Kefir.constant(messagesFetchFailed(err))),
                ]);
            }

            if (typeof route.parts.job === 'string') {
                const job = jobs[route.parts.job];

                if (!job) {
                    return Kefir.never();
                }

                const job$ = Kefir.concat([
                    Kefir.constant(jobFetchStarted()),
                    ajax$(job.rest_url, {
                        method: 'GET',
                        credentials: 'include',
                        headers: {
                            'X-WP-Nonce': globals.nonce,
                            'Content-Type': 'application/json'
                        }
                    })
                        .flatMap((response: ObsResponse) => response.json())
                        .map((response: GetJobResponse) => jobFetchSucceeded(response))
                        .flatMapErrors((err: TypeError) => Kefir.constant(jobFetchFailed(err))),
                ]);

                const runs$ = Kefir.concat([
                    Kefir.constant(runsFetchStarted()),
github calmm-js / karet.util / dist / karet.util.es.js View on Github external
var serially = function serially(xs) {
  return concat(xs.map(toObservable));
};
var parallel = function parallel(xs) {
github intraxia / wp-gistpen / client / deltas / commitsDelta.js View on Github external
.flatMapFirst((state: CommitsProps) =>
            Kefir.concat([
                Kefir.constant(commitsFetchStarted()),
                ajax$(state.repo.commits_url, {
                    method: 'GET',
                    credentials: 'include',
                    headers: {
                        'X-WP-Nonce': state.globals.nonce,
                        'Content-Type': 'application/json'
                    }
                })
                    .flatMap((response: ObsResponse) => response.json())
                    .map((response: GetCommitsResponse) => commitsFetchSucceeded(response))
                    .flatMapErrors((err: TypeError) => commitsFetchFailed(err)),
            ])
        );
github mAAdhaTTah / brookjs / packages / brookjs-cli / src / deltas / terminalDelta / log.js View on Github external
const error$ = actions$.flatMap(({ type, payload }) => {
        switch (type) {
            case SCAFFOLD_ERROR:
                return Kefir.concat([
                    ui.error(`error scaffolding file: ${payload.error.message}`),
                    setExitCode(1)
                ]);
            case READ_RC_FILE_ERROR:
                return Kefir.concat([
                    ui.error(`error reading .beaverrc.js: ${payload.error.message}`),
                    setExitCode(1)
                ]);
            default:
                return Kefir.never();
        }
    });

kefir

Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage

MIT
Latest version published 4 years ago

Package Health Score

57 / 100
Full package analysis