{% if book.isPdf==true %}
{% endif %}
Creates an observable sequence from a specified subscribe method implementation. This is an alias for the createWithDisposable
method
subscribe
(Function
): Implementation of the resulting observable sequence's subscribe method, optionally returning a function that will be wrapped in a disposable object. This could also be a disposable object.
(Observable
): The observable sequence with the specified implementation for the subscribe method.
{% if book.isPdf %}
/* Using a function */
var source = Rx.Observable.create(observer => {
observer.onNext(42);
observer.onCompleted();
// Note that this is optional, you do not have to return this if you require no cleanup
return () => console.log('disposed')
});
var subscription = source.subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: 42
// => onCompleted
subscription.dispose();
// => disposed
/* Using a disposable */
var source = Rx.Observable.create(observer => {
observer.onNext(42);
observer.onCompleted();
// Note that this is optional, you do not have to return this if you require no cleanup
return Rx.Disposable.create(() => console.log('disposed'));
});
var subscription = source.subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: 42
// => onCompleted
{% else %}
{% endif %}