According to the operator creation guide, i tried to chain some operators i used to an another operator but without any success.
function mySimpleOperator(actionName, iterable$, functionThatReturnAnObservable) {
return Observable.create(subscriber => {
var source = this;
var subscription = source
.interval(500)
.skipUntil(iterable$.filter(({ action }) => action.type === actionName))
.take(1)
.flatMap(functionThatReturnAnObservable)
.subscribe(value => {
try {
subscriber.next(value);
} catch(err) {
subscriber.error(err);
}
},
err => subscriber.error(err),
() => subscriber.complete());
return subscription;
});
}
Observable.prototype.mySimpleOperator = mySimpleOperator;
This function simply start an interval and will be skip until the actionName will be emitted.
But when i tried to use my operator
Observable.mySimpleOperator('APP_READY', source$, () => Observable.of({ type: 'DONE' })
It throw an error
Observable.mySimpleOperator is not a function
But if i do the intervall call outside my new operator it works ?!
Observable.interval(500).mySimpleOperatorWithoutIntervall('APP_READY', source$, () => Observable.of({ type: 'DONE' })
Any solutions ? :)