How to use the kefir.Observable 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-silt / src / __tests__ / toJunction.spec.tsx View on Github external
enabled
      }) => (
        
          <button>
        
      );
      const root$ = Kefir.pool();
      render();

      expect(root$).toEmit([value({ type: 'EMITTED' })], () =&gt; {
        send(source$, [value({ type: 'EMITTED' })]);
      });
      expect(combine).toHaveBeenCalledTimes(1);

      expect(combine).toHaveBeenCalledWith(
        expect.any(Kefir.Observable),
        {
          onButtonClick$: expect.any(Kefir.Observable),
          children$: expect.any(Kefir.Observable)
        },
        { text: 'Click me', enabled: true }
      );
    });
</button>
github calmm-js / kefir.react.html / test / tests.js View on Github external
const testEq = (expr, expect) => it(`${expr} => ${show(expect)}`, done => {
  const actual = eval(`(Atom, K, Kefir, R, bind, bindProps, classes) => ${expr}`)(Atom, K, Kefir, R, bind, bindProps, classes)
  const check = actual => {
    if (!R.equals(actual, expect))
      throw new Error(`Expected: ${show(expect)}, actual: ${show(actual)}`)
    done()
  }
  if (actual instanceof Kefir.Observable)
    actual.take(1).onValue(check)
  else
    check(actual)
})
github calmm-js / kefir.atom / test / tests.js View on Github external
Molecule,
  MutableWithSource,
  holding
} from '../dist/kefir.atom.cjs'

function show(x) {
  switch (typeof x) {
    case 'string':
    case 'object':
      return JSON.stringify(x)
    default:
      return `${x}`
  }
}

Kefir.Observable.prototype.orAsync = function(y) {
  return this.merge(Kefir.later(0, y))
}

const objectConstant = {x: 1}

const toExpr = f =>
  f
    .toString()
    .replace(/\s+/g, ' ')
    .replace(/^\s*function\s*\(\s*\)\s*{\s*(return\s*)?/g, '')
    .replace(/\s*;?\s*}\s*$/g, '')
    .replace(/function\s*(\([a-zA-Z0-9, ]*\))\s*/g, '$1 => ')
    .replace(/\(([a-z]+)\)\s*=>/g, '$1 =>')
    .replace(/{\s*return\s*([^{;]+)\s*;\s*}/g, '$1')
    .replace(/\(0, [^.]*[.]([^)]*)\)/g, '$1')
    .replace(/_kefirAtom[.]/g, '')
github calmm-js / kefir.atom / dist / kefir.atom.cjs.js View on Github external
var isObservable = function isObservable(x) {
  return x instanceof K.Observable;
};
github calmm-js / karet.util / src / karet.util.js View on Github external
const isObservable = x => x instanceof K.Observable
const isProperty = x => x instanceof K.Property
github mAAdhaTTah / brookjs / packages / brookjs / src / domDelta / index.js View on Github external
export default function domDelta({ el, view, selectProps }) {
    let precheck$ = Kefir.constant('Configuration correct');

    if (typeof el === 'function') {
        el = el(document);

        if (!(el instanceof Kefir.Observable)) {
            precheck$ = Kefir.constantError(new TypeError(`type ${typeof el} returned from el is not valid`));
        }
    } else if (el instanceof Element) {
        el = Kefir.constant(el);
    } else {
        precheck$ = Kefir.constantError(new TypeError(`el of type ${typeof el} is not valid`));
    }

    if (typeof view !== 'function') {
        precheck$ = Kefir.constantError(new TypeError(`component of type ${typeof el} is not valid`));
    }

    if (typeof selectProps !== 'function') {
        precheck$ = Kefir.constantError(new TypeError(`selectProps of type ${typeof el} is not valid`));
    }
github mAAdhaTTah / brookjs / packages / brookjs-silt / src / helpers.js View on Github external
export const isObs = x => x instanceof Kefir.Observable;
github calmm-js / kefir.react.html / src / combine.js View on Github external
function forEach(template, fn) {
  if (template instanceof Kefir.Observable) {
    fn(template)
  } else {
    const constructor = template &amp;&amp; template.constructor

    if (constructor === Array)
      for (let i=0, n=template.length; i
github calmm-js / kefir.atom / src / kefir.atom.js View on Github external
const isObservable = x => x instanceof K.Observable
github calmm-js / karet.util / dist / karet.util.cjs.js View on Github external
var isObservable = function isObservable(x) {
  return x instanceof K.Observable;
};
var isProperty = function isProperty(x) {

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