How to use the kefir.later 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 mAAdhaTTah / brookjs / packages / brookjs / src / domDelta / index.js View on Github external
.flatMap(isLoaded =>
            isLoaded ?
                // ensures async consistency
                Kefir.later(0, true) :
                Kefir.fromEvents(document, 'DOMContentLoaded')
        )
github StreakYC / react-menu-list / src / SubMenuItem.js View on Github external
// and end it there. Or end after a timer.
    Kefir.fromEvents(window, 'mousemove')
      .bufferBy(Kefir.interval(60, null))
      .map(events => {
        if (events.length) {
          const last = events[events.length-1];
          lastCoords = {pageX: last.pageX, pageY: last.pageY};
        }
        return lastCoords;
      })
      .filter(({pageX, pageY}) => {
        const distance = getDistance(pageX, pageY);
        const maxDistance = startDistance - (Date.now()-startTime-LEAD_TIME)/1000 * MIN_SPEED;
        return distance > maxDistance;
      })
      .merge(Kefir.later(MAX_TIME*1000))
      .take(1)
      .takeUntilBy(this._resetMouseLeaveWatcher)
      .takeUntilBy(this._stopper)
      .onValue(() => {
        this.close();
        menuItem.unhighlight();
      });
  }
github DefinitelyTyped / DefinitelyTyped / types / kefir / kefir-tests.ts View on Github external
let bar: Property  = Kefir.sequentially(200, [false, true, false]).delay(40).toProperty(() => true);
		let observable01: Stream = foo.filterBy(bar);
	}
	{
		let a: Property  = Kefir.sequentially(200, [2, 3]).toProperty(() => 1);
		let b: Stream  = Kefir.interval(100, 0).delay(40).take(5);
		let observable02: Property = a.sampledBy(b)
	}
	{
		let foo: Stream  = Kefir.sequentially(100, [1, 2, 3, 4]);
		let bar: Stream  = Kefir.later(250, 0);
		let observable03: Stream = foo.skipUntilBy(bar);
	}
	{
		let foo: Stream  = Kefir.sequentially(100, [1, 2, 3, 4]);
		let bar: Stream  = Kefir.later(250, 'hello');
		let observable04: Stream = foo.takeUntilBy(bar);
	}
	{
		let foo: Stream  = Kefir.sequentially(100, [1, 2, 3, 4, 5, 6, 7, 8]).delay(40);
		let bar: Stream  = Kefir.sequentially(300, [1, 2])
		let observable05: Stream = foo.bufferBy(bar);
	}
	{
		let foo: Stream  = Kefir.sequentially(100, [1, 2, 3, 4, 5, 6, 7, 8]);
		let bar: Stream  = Kefir.sequentially(200, [false, true, false]).delay(40);
		let observable06: Stream = foo.bufferWhileBy(bar);
	}
	{
		let foo: Stream  = Kefir.sequentially(100, [1, 2, 3]);
		let bar: Stream  = Kefir.sequentially(100, [1, 2, 3]).delay(40);
		let observable07: Stream = foo.awaiting(bar);
github calmm-js / karet / test / tests.js View on Github external
{[Kefir.constant('Hel'), [Kefir.constant('lo')]]}
    ,
    '<div style="display:block;color:red;background:green">Hello</div>'
  )

  testRender(
    <a href="{Kefir.constant('#lol')}" style="{Kefir.constant({color:">
      {Kefir.constant('Hello')} {Kefir.constant('world!')}
    </a>,
    '<a href="#lol" style="color:red">Hello world!</a>'
  )

  testRender(
    <div>
      {Kefir.constant(1)
        .merge(Kefir.later(1000, 0))
        .toProperty()}
    </div>,
    '<div>1</div>'
  )

  const Custom = ({prop, ...props}) =&gt; (
    <div>{`${prop} ${JSON.stringify(props)}`}</div>
  )

  testRender(
    ,
    '<div>[constant] {}</div>'
  )

  testRender(
    ,
github calmm-js / karet / test / tests.js View on Github external
'<div><div>a</div><div>b</div><div>c</div><div>d</div></div>'
  )

  testRender(
    <div>
      <div>a</div>
      {[
        <div>b</div>,
        Kefir.constant([<div>c</div>, [<div>d</div>]])
      ]}
    </div>,
    '<div><div>a</div><div>b</div><div>c</div><div>d</div></div>'
  )

  testRender(
    <div>,
    '<div>foo</div>'
  )

  const ChildrenWithSibling = ({children}) =&gt; <div>Test: {children}</div>

  testRender(
    Hello {Kefir.constant('world!')},
    '<div>Test: Hello world!</div>'
  )

  testRender(<span>0</span>, '<span>0</span>')
  testRender(<span>{Kefir.constant(0)}</span>, '<span>0</span>')

  testRender(
    <div>,
    '<div>oh yes</div>'</div></div>
github StreakYC / react-menu-list / src / SubMenuItem.js View on Github external
_onHighlightChange(highlighted: boolean, event: Object) {
    this._resetMouseLeaveWatcher.emit(null);

    if (highlighted && !event.byKeyboard) {
      const OPEN_DELAY = 200;

      Kefir.later(OPEN_DELAY)
        .takeUntilBy(this._resetMouseLeaveWatcher)
        .takeUntilBy(this._stopper)
        .onValue(() => {
          this.open();
        });
    } else if (!highlighted) {
      this.close();
    }
  }
github ivan-kleshnin / unredux / examples / 7.crud / server / ssr / index.js View on Github external
let timeoutError = (delayMs) =>
  K.later(delayMs, K.constantError(new Error("timeout"))).flatMap()
github intraxia / wp-gistpen / client / deltas / routerDelta.js View on Github external
return (actions$: Observable): Observable =&gt; {
        const initial$ = Kefir.later(0, router(getRoute(window.location.search, param)));

        const pushState$ = actions$.thru(ofType(routeChange)).flatMap(({ payload }: RouteChangeAction) =&gt; Kefir.stream((emitter: Emitter) =&gt; {
            const dest = getUrl(param, payload);

            if (dest !== (location.pathname + location.search)) {
                global.history.pushState({}, '', dest);
            }

            emitter.end();
        }));

        const href$ = Kefir.stream((emitter: Emitter) =&gt; {
            const emit = ({ search, href }: HrefTarget) =&gt; {
                if (typeof search === 'string') {
                    search = parseQueryString(search);
                }
github mAAdhaTTah / brookjs / packages / brookjs-cli / src / deltas / terminalDelta / newCommandPrompt.js View on Github external
const prompt$ = state$.take(1).flatMap(state =>
        state.command.opts.yes === true
            ? Kefir.later(0, initConfigResponse({ ...defaultConfig, name: state.command.args.name }))
            : ui.prompt([
                {
                    type: 'input',
                    name: 'version',
                    message: 'What is the application version?',
                    default: defaultConfig.version
                },
                {
                    type: 'input',
                    name: 'description',
                    message: 'What is the application description?',
                    default: defaultConfig.description
                },
                {
                    type: 'input',
                    name: 'dir',

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