How to use @cycle/time - 7 common examples

To help you get started, we’ve selected a few @cycle/time 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 MCS-Lite / mcs-lite / packages / mcs-lite-mobile-web / src / utils / helpers.js View on Github external
export function assertSourcesSinks(sources, sinks, main, done, timeOpts = {}) {
  const Time = mockTimeSource(timeOpts);
  const _sources = Object.keys(sources).reduce((_sources, sourceKey) => {
    const sourceObj = sources[sourceKey];
    const diagram = Object.keys(sourceObj)[0];
    const sourceOpts = sourceObj[diagram];

    let obj = {};
    let firstKey = Object.keys(sourceOpts)[0];
    if (typeof sourceOpts[firstKey] === 'function') {
      obj = {
        [sourceKey]: {
          // pass category to select
          [firstKey]: (...args) =>
            Time.diagram(diagram, sourceOpts[firstKey](...args)),
        },
      };
    } else {
github MCS-Lite / mcs-lite / packages / mcs-lite-admin-web / src / utils / helpers.js View on Github external
export function assertSourcesSinks(sources, sinks, main, done, timeOpts = {}) {
  const Time = mockTimeSource(timeOpts);
  const _sources = Object.keys(sources).reduce((_sources, sourceKey) => {
    const sourceObj = sources[sourceKey];
    const diagram = Object.keys(sourceObj)[0];
    const sourceOpts = sourceObj[diagram];

    let obj = {};
    let firstKey = Object.keys(sourceOpts)[0];
    if (typeof sourceOpts[firstKey] === 'function') {
      obj = {
        [sourceKey]: {
          // pass category to select
          [firstKey]: (...args) =>
            Time.diagram(diagram, sourceOpts[firstKey](...args)),
        },
      };
    } else if (firstKey === 'local') {
github cyclejs / cycle-time-travel / src / time-travel.ts View on Github external
function run (app, makeDrivers) {
  const Time = timeDriver(null, null);

  const newMakeDrivers = () => {
    const drivers = makeDrivers();

    drivers.Time = () => Time;

    return drivers;
  }

  const rerun = rerunner(originalRun, newMakeDrivers);

  const stuff = rerun(app);

  const awesomeStreams = streamGraph(stuff.sinks);

  function InnerApp (sources) {
github Widdershin / cycle-restart / src / restart.js View on Github external
function restart (setup, main, drivers, cb, {sources, sinks, dispose}, isolate = {}, timeToTravelTo = null) {
  dispose();

  if (typeof isolate === 'function' && 'reset' in isolate) {
    isolate.reset();
  }

  const realTime = timeDriver();
  realTime._pause();

  drivers.Time = () => realTime;

  for (let driverName in drivers) {
    const driver = drivers[driverName];

    const newDriver = (sink$) => driver(sink$, realTime);

    newDriver.replayLog = driver.replayLog;
    newDriver.onPostReplay = driver.onPostReplay;
    newDriver.log$ = driver.log$;

    drivers[driverName] = newDriver;

    if (driver.onPreReplay) {
github Widdershin / cycle-restart / src / restart.js View on Github external
return function(main, cb = noop, timeToTravelTo = null) {
    if (first) {
      drivers = driversFn();

      let realTime = timeDriver();
      drivers.Time = () => realTime;

      for (let driverName in drivers) {
        const driver = drivers[driverName];

        const newDriver = (sink$) => driver(sink$, realTime);

        drivers[driverName] = newDriver;
      }

      const {sources, sinks, run} = Cycle(main, drivers);

      realTime = sources.Time;

      const dispose = run();
github cyclejs / cyclejs / most-time / src / index.ts View on Github external
export function mockTimeSource(args?: Object): MockTimeSource {
  return mockTimeSourceUntyped(args);
}
github cyclejs / cyclejs / most-time / src / index.ts View on Github external
export function timeDriver(sink: any): TimeSource {
  return timeDriverUntyped(sink);
}

@cycle/time

A time driver designed to enable awesome testing and dev tooling

MIT
Latest version published 4 years ago

Package Health Score

59 / 100
Full package analysis