How to use the @cycle/run/lib/adapt.adapt 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 / collection / src / collection.js View on Github external
// single item
        return collection.add(sourcesList);
      }
    });
    const removeReducer$ = removeProxy$.map(item => collection => collection.remove(item));
    const reducer$ = xs.merge(removeReducer$, addReducer$);

    const emptyCollection = collection({ component, sources, removeSelector });
    const collection$ = reducer$
      .fold((collection, reducer) => reducer(collection), emptyCollection)
      .map(collection => collection.asArray());

    const remove$ = Collection.merge(collection$, item => item._remove$, true);
    removeProxy$.imitate(remove$);

    return adapt(collection$);
  }
github cyclejs / storage / src / util.ts View on Github external
key(n: number) {
      return adapt(storageKey(n, request$, type));
    },
    // Function returning stream of item values.
github aronallen / cycle-sandbox / src / sandbox.ts View on Github external
const sandbox: ISpawn = (
      resource,
      sources,
      bridges = {}
    ) => {
      let channels: MessageChannels;
      let subscription: FantasySubscription;
      let worker: Worker;
      let receivePorts: MessagePorts = {};
      const instanceId = uuid();
      return adapt(xs.create({
        start (observer) {
          const sourceKeys = Object.keys(sources);
          channels = createChannels(sourceKeys);
          // { DOM: channel}

          worker = open(resource);

          // make a object of destination ports (rx in thread) wiil be transfered to thread
          const transferPorts = portMap(channels, 2);
          
          // make a object of entry ports (tx in main)
          const sendPorts = portMap(channels, 1);

          const message: SandboxMessage = {
            cmd: SandboxMessageCommand.init,
            ports: transferPorts,
github cyclejs-community / cyclic-router / test / rxjs.js View on Github external
.path('/some')
                    .path('/nested')
                    .define(defintion);
                match$.subscribe(({ path, value, location }) => {
                    assert.strictEqual(path, '/correct/route');
                    assert.strictEqual(value, 123);
                    assert.strictEqual(
                        location.pathname,
                        '/some/nested/correct/route'
                    );
                    done();
                });
                return {};
            };
            routerify(app, switchPath)({
                history: adapt(
                    makeServerHistoryDriver()(
                        of('/wrong/path', '/some/nested/correct/route').pipe(
                            delay(0)
                        )
                    )
                )
            });
        });
github cyclejs-community / cyclejs-modal / src / modalify.ts View on Github external
return function(sources: Sources): Sinks {
        const messageProxy$: Stream = xs.create();

        const parentSinks: Sinks = main({
            ...sources,
            [name]: adapt(messageProxy$)
        });

        const sinks: Sinks = Object.keys(parentSinks)
            .map(k => ({ [k]: xs.fromObservable(parentSinks[k]) }))
            .reduce((prev, curr) => Object.assign(prev, curr), {});

        if (sinks[name]) {
            const modalProxy$: Stream = xs.create();
            const modalStack$: Stream = xs
                .merge(sinks[name] as Stream, modalProxy$)
                .fold((acc, curr) => {
                    if (curr.type === 'close') {
                        const count: number = curr.count || 1;
                        return acc.slice(0, Math.max(acc.length - count, 0));
                    } else if (curr.type === 'open') {
                        const _sources: Sources =
github cyclejs / cyclejs / dom / src / HTMLSource.ts View on Github external
constructor(html$: Stream, private _name: string) {
    this._html$ = html$;
    this._empty$ = adapt(xs.empty());
  }
github cyclejs-community / cyclic-router / src / RouterSource.ts View on Github external
define(
        routes: RouteDefinitionsMap | RouteDefinitionsArray,
        routeMatcher?: RouteMatcher
    ): any {
        const _createHref = this._createHref;
        const createHref = util.makeCreateHref(this._namespace, _createHref);

        const out$ = adapt(this._define(routes, routeMatcher));
        out$.createHref = createHref;
        return out$;
    }
github cyclejs / cyclejs / time / src / throttle-animation.ts View on Github external
listener.complete();
          },
        };

        stream.addListener(animationListener);
        frame$.addListener(frameListener);
      },

      stop() {
        if (animationListener) {
          stream.removeListener(animationListener);
        }
      },
    });

    return adapt(throttledStream);
  };
}
github cyclejs-community / cycle-canvas / src / canvas-driver.js View on Github external
const rootElementWithDefaults = Object.assign(
          {},
          defaults,
          rootElement
        )

        const instructions = translateVtreeToInstructions(rootElementWithDefaults)

        renderInstructionsToCanvas(instructions, context)
      },
      error: e => { throw e },
      complete: () => null
    })

    return adapt(xs.empty())
  }
github cyclejs / cyclejs / isolate / src / index.ts View on Github external
function isolateAllSinks(
  sources: So,
  innerSinks: Si,
  scopes: ScopesPerChannel
): Si {
  const outerSinks = {} as Si;
  for (const channel in innerSinks) {
    const source = sources[channel] as IsolateableSource;
    const innerSink = innerSinks[channel];
    if (
      innerSinks.hasOwnProperty(channel) &&
      source &&
      scopes[channel] !== null &&
      typeof source.isolateSink === 'function'
    ) {
      outerSinks[channel] = adapt(
        source.isolateSink(xs.fromObservable(innerSink as any), scopes[channel])
      );
    } else if (innerSinks.hasOwnProperty(channel)) {
      outerSinks[channel] = innerSinks[channel];
    }
  }
  return outerSinks;
}

@cycle/run

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

MIT
Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis