How to use the @cycle/run/lib/adapt.setAdapt function in @cycle/run

To help you get started, we’ve selected a few @cycle/run 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 cyclejs / cyclejs / most-run / src / index.ts View on Github external
export interface CycleProgram<
  D extends MatchingDrivers,
  M extends MatchingMain
> {
  sources: ToMostStreams>;
  sinks: Sinks;
  run(): DisposeFunction;
}

export interface Engine {
  sources: Sources;
  run>(sinks: Sinks): DisposeFunction;
  dispose(): void;
}

setAdapt(function adaptXstreamToMost(stream: Stream): MostStream {
  return most.from(stream as any);
});

/**
 * Takes a `main` function and circularly connects it to the given collection
 * of driver functions.
 *
 * **Example:**
 * ```js
 * import run from '@cycle/most-run';
 * const dispose = run(main, drivers);
 * // ...
 * dispose();
 * ```
 *
 * The `main` function expects a collection of "source" streams (returned from
github shesek / spark-wallet / client / src / app.js View on Github external
import model  from './model'
import view   from './view'
import rpc    from './rpc'

if (process.env.BUILD_TARGET === 'web') {
  require('pwacompat')
}

// Send Cordova/Electron users directly to server settings if there are none
if (process.env.BUILD_TARGET !== 'web' && !localStorage.serverInfo) {
  location.href = 'settings.html' // @xxx side-effects outside of drivers
  throw new Error('Missing server settings, redirecting')
}

// Get cyclejs to use rxjs-compat-enabled streams
require("@cycle/run/lib/adapt").setAdapt(stream$ => O.from(stream$))

const serverInfo = process.env.BUILD_TARGET === 'web'
  ? { serverUrl: '.', accessKey: document.querySelector('[name=access-key]').content }
  : JSON.parse(localStorage.serverInfo)

const main = ({ DOM, HTTP, SSE, route, conf$, scan$, urihandler$ }) => {

  const actions = intent({ DOM, route, conf$, scan$, urihandler$ })
      , resps   = rpc.parseRes({ HTTP, SSE })

      , state$  = model({ HTTP, ...actions, ...resps })

      , rpc$     = rpc.makeReq(actions)
      , vdom$    = view.vdom({ state$, ...actions, ...resps })
      , navto$   = view.navto({ ...resps, ...actions })
      , notif$   = view.notif({ state$, ...resps })
github shesek / spark-wallet / client / src / server-settings.js View on Github external
import urlutil from 'url'
import run from '@cycle/rxjs-run'
import serialize from 'form-serialize'
import { Observable as O } from './rxjs'
import { makeDOMDriver } from '@cycle/dom'
import { makeHashHistoryDriver, captureClicks } from '@cycle/history'
import storageDriver from '@cycle/storage'

// Get cyclejs to use rxjs-compat-enabled streams
require("@cycle/run/lib/adapt").setAdapt(stream$ => O.from(stream$))

import makeRouteDriver from './driver/route'
import makeConfDriver  from './driver/conf'

import { combine, dbg } from './util'

import { layout } from './views/layout'
import view from './views/server-settings'

// Settings manager for Cordova/Electron builds.
// This is a standalone cycle app loaded using a separate HTML file (settings.html).

const main = ({ DOM, IPC, storage, route, conf$, scan$ }) => {
  const
    on = (sel, ev, pd=false) => DOM.select(sel).events(ev, { preventDefault: pd })
github cyclejs / cyclejs / rxjs-run / src / index.ts View on Github external
export interface CycleProgram<
  D extends MatchingDrivers,
  M extends MatchingMain
> {
  sources: ToObservables>;
  sinks: Sinks;
  run(): DisposeFunction;
}

export interface Engine {
  sources: Sources;
  run>(sinks: Sinks): DisposeFunction;
  dispose(): void;
}

setAdapt(function adaptXstreamToRx(stream: Stream): Observable {
  return from(stream as any);
});

/**
 * Takes a `main` function and circularly connects it to the given collection
 * of driver functions.
 *
 * **Example:**
 * ```js
 * import run from '@cycle/rxjs-run';
 * const dispose = run(main, drivers);
 * // ...
 * dispose();
 * ```
 *
 * The `main` function expects a collection of "source" Observables (returned

@cycle/run

The Cycle.js run() function to use with xstream

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis