How to use the zen-observable.of function in zen-observable

To help you get started, we’ve selected a few zen-observable 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 sw-yx / reactive-react / build / reactive-react.es.js View on Github external
function renderStream(element, instance, state, stateMap) {
  // this is a separate function because scope gets messy when being recursive
  var isNewStream = false; // assume no stream switching by default
  // this is the first ping of data throughout the app
  var source = Observable.of(state);
  var addToStream = function addToStream(_source) {
    // visit each source and merge with source
    if (_source) return source = merge(source, _source);
  };
  var markNewStream = function markNewStream() {
    return isNewStream = true;
  };
  var newInstance = render(source, addToStream, markNewStream)(element, instance, state, stateMap);
  return { source: source, instance: newInstance, isNewStream: isNewStream };
}
github kefirjs / kefir / test / specs / from-es-observable.js View on Github external
it('turns an ES7 observable into a stream', () => {
    expect(Kefir.fromESObservable(Observable.of(1, 2))).to.be.observable.stream()
  })
github avajs / ava / test / observable.js View on Github external
return ava.cb(a => {
		a.plan(2);

		const observable = Observable.of();

		setImmediate(() => {
			a.pass();
			a.pass();
			a.end();
		});

		return observable;
	}).run().then(result => {
		t.is(result.passed, false);
github DefinitelyTyped / DefinitelyTyped / types / zen-observable / zen-observable-tests.ts View on Github external
* observable.filter
 */

Observable.of(1, 2, 3)
    .filter(val => val !== 2)
    .subscribe(val => assert(typeof val === 'number' && val !== 2));

/**
 * observable.reduce
 */

Observable.of(1, 2, 3)
    .reduce((acc, val) => acc + val)
    .subscribe(val => assert(val === 6));

Observable.of(1, 2, 3)
    .reduce((acc, val) => acc + val, '')
    .subscribe(val => assert(val === '123'));

/**
 * observable.flatMap
 */

Observable.of(1, 2, 3)
    .flatMap(val => Observable.of(val.toString()))
    .subscribe(val => assert(typeof val === 'string'));

/**
 * ZenObservable
 */

let subscriptionObserver: ZenObservable.SubscriptionObserver;
github DefinitelyTyped / DefinitelyTyped / types / zen-observable / zen-observable-tests.ts View on Github external
* observable.reduce
 */

Observable.of(1, 2, 3)
    .reduce((acc, val) => acc + val)
    .subscribe(val => assert(val === 6));

Observable.of(1, 2, 3)
    .reduce((acc, val) => acc + val, '')
    .subscribe(val => assert(val === '123'));

/**
 * observable.flatMap
 */

Observable.of(1, 2, 3)
    .flatMap(val => Observable.of(val.toString()))
    .subscribe(val => assert(typeof val === 'string'));

/**
 * ZenObservable
 */

let subscriptionObserver: ZenObservable.SubscriptionObserver;
let subscription: ZenObservable.Subscription;
let observer: ZenObservable.Observer;
let subscriber: ZenObservable.Subscriber;
let observableLike: ZenObservable.ObservableLike;
github newsuk / times-components / packages / provider-test-tools / src / mocked-provider.js View on Github external
      ? new ApolloLink(() => Observable.of())
      : new MockLink(props.mocks);
github DefinitelyTyped / DefinitelyTyped / types / zen-observable / zen-observable-tests.ts View on Github external
/**
 * Observable
 */

new Observable(observer => {
    [1, 2, 3].forEach(one => observer.next(one));
    observer.complete();
})
    .subscribe(val => assert(typeof val === 'number'));

/**
 * Observable.of
 */

Observable.of(1, 2, 3)
    .subscribe(val => assert(typeof val === 'number'));

/**
 * Observable.from
 */

Observable.from(Observable.of(1, 2, 3))
    .subscribe(val => assert(typeof val === 'number'));

Observable.from([1, 2, 3])
    .subscribe(val => assert(typeof val === 'number'));

Observable.from({
    subscribe(observer: ZenObservable.SubscriptionObserver) {
        [1, 2, 3].forEach(one => observer.next(one));
        observer.complete();
github DefinitelyTyped / DefinitelyTyped / types / zen-observable / zen-observable-tests.ts View on Github external
Observable.of(1, 2, 3)
    .forEach(val => assert(typeof val === 'number'));

/**
 * observable.map
 */

Observable.of(1, 2, 3)
    .map(val => val.toString())
    .subscribe(val => assert(typeof val === 'string'));

/**
 * observable.filter
 */

Observable.of(1, 2, 3)
    .filter(val => val !== 2)
    .subscribe(val => assert(typeof val === 'number' && val !== 2));

/**
 * observable.reduce
 */

Observable.of(1, 2, 3)
    .reduce((acc, val) => acc + val)
    .subscribe(val => assert(val === 6));

Observable.of(1, 2, 3)
    .reduce((acc, val) => acc + val, '')
    .subscribe(val => assert(val === '123'));

/**
github DefinitelyTyped / DefinitelyTyped / types / zen-observable / zen-observable-tests.ts View on Github external
}
})
    .subscribe(val => assert(typeof val === 'number'));

Observable.from({
    [Symbol.observable]() {
        return Observable.of(1, 2, 3);
    }
})
    .subscribe(val => assert(typeof val === 'number'));

/**
 * observable.forEach
 */

Observable.of(1, 2, 3)
    .forEach(val => assert(typeof val === 'number'));

/**
 * observable.map
 */

Observable.of(1, 2, 3)
    .map(val => val.toString())
    .subscribe(val => assert(typeof val === 'string'));

/**
 * observable.filter
 */

Observable.of(1, 2, 3)
    .filter(val => val !== 2)
github OriginProtocol / origin / packages / graphql / src / link.js View on Github external
const link = new ApolloLink(operation => {
  const definition = getMainDefinition(operation.query)
  if (definition.operation === 'subscription') {
    return subscriptionLink.request(operation) || Observable.of()
  } else if (context && context.config && context.config.performanceMode) {
    return remoteSchemaLink.request(operation) || Observable.of()
  } else {
    return schemaLink.request(operation) || Observable.of()
  }
})

zen-observable

An Implementation of ES Observables

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis

Similar packages