Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 };
}
it('turns an ES7 observable into a stream', () => {
expect(Kefir.fromESObservable(Observable.of(1, 2))).to.be.observable.stream()
})
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);
* 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;
* 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;
? new ApolloLink(() => Observable.of())
: new MockLink(props.mocks);
/**
* 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();
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'));
/**
}
})
.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)
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()
}
})