Rx.Observable.defer(observableFactory)

Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.

Arguments

  1. observableFactory (Function): Observable factory function to invoke for each observer that subscribes to the resulting sequence.

Returns

(Observable): An observable sequence whose observers trigger an invocation of the given observable factory function.

Example

Using an observable sequence

Using a promise