
TheUsing operator is a way you can instruct an Observable to create a resource that exists only during the lifespan of the Observable and is disposed of when the Observable terminates.
TBD
TBD

You pass theusing operator three parameters:
When an observer subscribes to the Observable returned fromusing,using will use the Observable factory function to create the Observable the observer will observe, while at the same time using the resource factory function to create whichever resource you have designed it to make. When the observer unsubscribes from the Observable, or when the Observable terminates (normally or with an error),using will call the third function to dispose of the resource it created.
using does not by default operate on any particularScheduler.
using(Func0,Func1,Action1)
You pass theusing operator three parameters:
When an observer subscribes to the Observable returned fromusing,using will use the Observable factory function to create the Observable the observer will observe, while at the same time using the resource factory function to create whichever resource you have designed it to make. When the observer unsubscribes from the Observable, or when the Observable terminates (normally or with an error),using will call the third function to dispose of the resource it created.
using does not by default operate on any particularScheduler.
using(Func0,Func1,Action1)
You pass theusing operator two parameters:
When an observer subscribes to the Observable returned fromusing,using will use the Observable factory function to create the Observable the observer will observe, while at the same time using the resource factory function to create whichever resource you have designed it to make. To dispose of the resource, call thedispose method of the subscription that was returned from thesubscribe call you used to subscribe an observer to the Observable that you modified withusing.
/* Using an AsyncSubject as a resource which supports the .dispose method */function DisposableResource(value) { this.value = value; this.disposed = false;}DisposableResource.prototype.getValue = function () { if (this.disposed) { throw new Error('Object is disposed'); } return this.value;};DisposableResource.prototype.dispose = function () { if (!this.disposed) { this.disposed = true; this.value = null; } console.log('Disposed');};var source = Rx.Observable.using( function () { return new DisposableResource(42); }, function (resource) { var subject = new Rx.AsyncSubject(); subject.onNext(resource.getValue()); subject.onCompleted(); return subject; });var subscription = source.subscribe( function (x) { console.log('Next: ' + x); }, function (err) { console.log('Error: ' + err); }, function () { console.log('Completed'); });Next: 42Completed
subscription.dispose();
Disposed
using is found in each of the following distributions:
rx.jsrx.compat.jsTBD
TBD
TBD
TBD
TBD