C where is observable




















The observer connects to the observable using the subscribe method to run a block of code. An observable instance passes through the four phases of its life cycle with the aid of observers and subscriptions: construct, subscribe, execute, and destroy. Now, let's look at subscribing to an observable. To get the observable to start execution, utilize the subscribe method. Because the Observer is in charge of executing instructions on the Observable, each observer subscriber can supply the Observer with three values.

The observer sends a value, which might be a number, string, or object, with each consecutive value. For every given Observable, there will be several sets of approaching notifications.

The observer will raise a JavaScript exception with a value of error. If an error occurs in the Observable, no additional data may be sent to the Observable. The observer does not send any value, therefore the value is complete. This often indicates that the subscription to a certain Observable has been completed. You can see in your console window that either the error value or the Complete value automatically pauses execution, indicating that this is an asynchronous example.

Destroying an Observable simply means unsubscribing from it and removing it from the DOM. RxJS typically handles unsubscribe for asynchronous functionality, and the observable is destroyed as soon as an error message or full message is destroyed. View All. Gurpreet Arora Updated date Sep 03, Understanding Observables To observe Observables, you must first comprehend the pull and push context.

Understanding Stream A stream is just a series of information prices across time. Casts the elements of an IEnumerable to the specified type. Splits the elements of a sequence into chunks of size at most size. Determines whether a sequence contains a specified element by using the default equality comparer. Returns a number that represents how many elements in the specified sequence satisfy a condition. Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.

Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty. Returns distinct elements from a sequence by using the default equality comparer to compare values. Returns distinct elements from a sequence according to a specified key selector function and using a specified comparer to compare keys.

Returns the element at a specified index in a sequence or a default value if the index is out of range. Produces the set difference of two sequences by using the default equality comparer to compare values. Returns the first element of a sequence, or a default value if the sequence contains no elements. Returns the first element of a sequence, or a specified default value if the sequence contains no elements.

Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.

Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer. Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.

Groups the elements of a sequence according to a key selector function. The keys are compared by using a comparer and each group's elements are projected by using a specified function.

Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The keys are compared by using a specified comparer. The elements of each group are projected by using a specified function. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function.

Correlates the elements of two sequences based on equality of keys and groups the results. The default equality comparer is used to compare keys. Correlates the elements of two sequences based on key equality and groups the results. Produces the set intersection of two sequences by using the default equality comparer to compare values. Correlates the elements of two sequences based on matching keys. Returns the last element of a sequence, or a specified default value if the sequence contains no elements.

Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. Returns the last element of a sequence that satisfies a condition, or a specified default value if no such element is found. Returns an Int64 that represents the total number of elements in a sequence. Returns an Int64 that represents how many elements in a sequence satisfy a condition.

Invokes a transform function on each element of a sequence and returns the maximum Decimal value. Invokes a transform function on each element of a sequence and returns the maximum Double value. Invokes a transform function on each element of a sequence and returns the maximum Int32 value. Invokes a transform function on each element of a sequence and returns the maximum Int64 value. Invokes a transform function on each element of a sequence and returns the maximum nullable Decimal value.

Invokes a transform function on each element of a sequence and returns the maximum nullable Double value. Invokes a transform function on each element of a sequence and returns the maximum nullable Int32 value. Invokes a transform function on each element of a sequence and returns the maximum nullable Int64 value. Invokes a transform function on each element of a sequence and returns the maximum nullable Single value.

Invokes a transform function on each element of a sequence and returns the maximum Single value. Invokes a transform function on each element of a generic sequence and returns the maximum resulting value. Returns the maximum value in a generic sequence according to a specified key selector function and key comparer. Invokes a transform function on each element of a sequence and returns the minimum Decimal value. Invokes a transform function on each element of a sequence and returns the minimum Double value.

Invokes a transform function on each element of a sequence and returns the minimum Int32 value. Invokes a transform function on each element of a sequence and returns the minimum Int64 value.

Invokes a transform function on each element of a sequence and returns the minimum nullable Decimal value. Invokes a transform function on each element of a sequence and returns the minimum nullable Double value.

Invokes a transform function on each element of a sequence and returns the minimum nullable Int32 value. Invokes a transform function on each element of a sequence and returns the minimum nullable Int64 value. Invokes a transform function on each element of a sequence and returns the minimum nullable Single value. Invokes a transform function on each element of a sequence and returns the minimum Single value.

Invokes a transform function on each element of a generic sequence and returns the minimum resulting value. Returns the minimum value in a generic sequence according to a specified key selector function and key comparer.

Filters the elements of an IEnumerable based on a specified type. The index of each source element is used in the projected form of that element. The index of each source element is used in the intermediate projected form of that element.

Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type. Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

Returns the only element of a sequence, or a specified default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence. Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition. Returns the only element of a sequence that satisfies a specified condition, or a specified default value if no such element exists; this method throws an exception if more than one element satisfies the condition.

Returns a new enumerable collection that contains the elements from source with the last count elements of the source collection omitted.

Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function. Computes the sum of the sequence of Decimal values that are obtained by invoking a transform function on each element of the input sequence. If you provide selector function, multicast returns just a regular Observable, instead of ConnectableObservable.

Thus, as usual, each subscription to this stream triggers subscription to the source Observable. However, if inside the selector function you subscribe to the input Observable multiple times, actual source stream will be subscribed only once. So if you have a chain of operators that use some Observable many times, but you want to subscribe to that Observable only once, this is the mode you would use. Subject provided as a first parameter of multicast is used as a proxy for the single subscription to the source Observable.

It means that all values from the source stream go through that Subject. Thus, if a Subject has some special properties, Observable returned by multicast will have them as well. These are actually just wrappers around multicast , with a specific Subject hardcoded inside. Also, if you use publish or publishReplay with a ConnectableObservables refCount operator, you can simply use share and shareReplay respectively, which chain these two. Factory function to create an intermediate Subject through which the source sequence's elements will be multicast to the selector function input Observable or ConnectableObservable returned by the operator.

Optional selector function that can use the input stream as many times as needed, without causing multiple subscriptions to the source stream. Subscribers to the input source will receive all notifications of the source from the time of the subscription forward. An Observable that emits the results of invoking the selector on the source stream or a special ConnectableObservable , if selector was not provided.

Ensure a specific scheduler is used, from outside of an Observable. It might be useful, if you do not have control over internal scheduler of a given Observable, but want to control when its values are emitted nevertheless. Returned Observable emits the same notifications nexted values, complete and error events as the source Observable, but rescheduled with provided scheduler.

Note that this doesn't mean that source Observables internal scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits notification, it will be immediately scheduled again - this time with scheduler passed to observeOn. An anti-pattern would be calling observeOn on Observable that emits lots of values synchronously, to split that emissions into asynchronous chunks.

For this to happen, scheduler would have to be passed into the source Observable directly usually into the operator that creates it.

As a matter of fact, observeOn accepts second parameter, which specifies in milliseconds with what delay notifications will be emitted. The main difference between delay operator and observeOn is that observeOn will delay all notifications - including error notifications - while delay will pass through error from source Observable immediately when it is emitted. In general it is highly recommended to use delay operator for any kind of delaying of values in the stream, while using observeOn to specify which scheduler should be used for notification emissions in general.

Observable that emits the same notifications as the source Observable, but with provided scheduler. Execute series of Observables no matter what, even if it means swallowing errors. If no single Observable is provided, returned Observable will simply behave the same as the source. When its stream of values ends - no matter if Observable completed or emitted an error - onErrorResumeNext will subscribe to the first Observable that was passed as an argument to the method.

It will start re-emitting its values as well and - again - when that stream ends, onErrorResumeNext will proceed to subscribing yet another Observable in provided series, no matter if previous Observable completed or ended with an error.

This will be happening until there is no more Observables left in the series, at which point returned Observable will complete - even if the last subscribed stream ended with an error.

While concat subscribes to the next Observable in series only if previous one successfully completed, onErrorResumeNext subscribes even if it ended with an error. Note that you do not get any access to errors emitted by the Observables. In particular do not expect these errors to appear in error callback passed to subscribe. If you want to take specific actions based on what error was emitted by an Observable, you should try out catch instead. An Observable that emits values from source Observable, but - if it errors - subscribes to the next passed Observable and so on, until it completes or runs out of Observables.

Puts the current value and previous value together as an array, and emits that. The Nth emission from the source Observable will cause the output Observable to emit an array [ N-1 th, Nth] of the previous and the current value, as a pair. For this reason, pairwise emits on the second and subsequent emissions from the source Observable, but not on the first emission, because there is no previous value in that case.

The first Observable in that array emits source values for which the predicate argument returns true. The second Observable emits source values for which the predicate returns false. The first behaves like filter and the second behaves like filter with the predicate negated. If it returns true , the value is emitted on the first Observable in the returned array, if false the value is emitted on the second Observable in the array.

An array with two Observables: one with values that passed the predicate, and another with values that did not pass the predicate. Like map , but meant only for picking one of the nested properties of every emitted object. Given a list of strings describing a path to an object property, retrieves the value of a specified nested property from all values in the source Observable. If a property can't be resolved, it will return undefined for that value. Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence.

Subscribers to the given source will receive all notifications of the source from the time of the subscription on. A ConnectableObservable that upon connection causes the source Observable to emit items to its Observers.

Combines together all values emitted on the source, using an accumulator function that knows how to join a new source value into the accumulation from the past. Note that reduce will only emit one value, only when the source Observable completes. It is equivalent to applying operator scan followed by operator last. Returns an Observable that applies a specified accumulator function to each item emitted by the source Observable.

If a seed value is specified, then that value will be used as the initial value for the accumulator. If no seed value is specified, the first item of the source is used as the seed. An Observable that emits a single value that is the result of accumulating the values emitted by the source Observable. The number of times the source Observable items are repeated, a count of 0 will yield an empty Observable. An Observable that repeats the stream of items emitted by the source Observable at most count times.

If the source Observable calls complete , this method will emit to the Observable returned from notifier. If that Observable calls complete or error , then this method will call complete or error on the child subscription. Otherwise this method will resubscribe to the source Observable.

Receives an Observable of notifications with which a user can complete or error , aborting the repetition. If the source Observable calls error , this method will resubscribe to the source Observable for a maximum of count resubscriptions given as a number parameter rather than propagating the error call. Any and all items emitted by the source Observable will be emitted by the resulting Observable, even those emitted during failed subscriptions.

For example, if an Observable fails at first but emits [1, 2] then succeeds the second time and emits: [1, 2, 3, 4, 5] then the complete stream of emissions and notifications would be: [1, 2, 1, 2, 3, 4, 5, complete ].

If the source Observable calls error , this method will emit the Throwable that caused the error to the Observable returned from notifier. If that Observable calls complete or error then this method will call complete or error on the child subscription. Receives an Observable of notifications with which a user can complete or error , aborting the retry. It's like sampleTime , but samples whenever the notifier Observable emits something. Whenever the notifier Observable emits a value or completes, sample looks at the source Observable and emits whichever value it has most recently emitted since the previous sampling, unless the source has not emitted anything since the previous sampling.

The notifier is subscribed to as soon as the output Observable is subscribed. An Observable that emits the results of sampling the values emitted by the source Observable whenever the notifier Observable emits value or completes.

Samples the source Observable at periodic time intervals, emitting what it samples. The sampling happens periodically in time every period milliseconds or the time unit defined by the optional scheduler argument. The sampling starts as soon as the output Observable is subscribed. The sampling period expressed in milliseconds or the time unit determined internally by the optional scheduler.

An Observable that emits the results of sampling the values emitted by the source Observable at the specified time interval. It's like reduce , but emits the current accumulation whenever the source emits a value. Is similar to reduce , but emits the intermediate accumulations. Checks to see of all values emitted by both observables are equal, in order.

Whenever either observable emits a value, the value is buffered and the buffers are shifted and compared from the bottom up; If any value pair doesn't match, the returned observable will emit false and complete. If one of the observables completes, the operator will wait for the other observable to complete; If the other observable emits before completing, the returned observable will emit false and complete.

If one observable never completes or emits after the other complets, the returned observable will never complete. An Observable of a single boolean value representing whether or not the values emitted by both observables were equal in sequence. Returns a new Observable that multicasts shares the original Observable. As long as there is at least one Subscriber this Observable will be subscribed and emitting data.

When all subscribers have unsubscribed it will unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream hot. This behaves similarly to. This is an alias for. An Observable that emits the single item emitted by the source Observable that matches the predicate.

As more values are received, values are taken from the front of the queue and produced on the result sequence. This causes values to be delayed. The second Observable that has to emit an item before the source Observable's elements begin to be mirrored by the resulting Observable. An Observable that skips items from the source Observable until the second Observable emits an item, then emits the remaining items.

An Observable that begins emitting items emitted by the source Observable when the specified predicate becomes false. An Observable that emits the items in the specified Iterable and then emits the items emitted by the source Observable. Use it when you have all these Observables, but still nothing is happening. It might be for example a function that you passed to a create static factory, but most of the time it is a library implementation, which defines what and when will be emitted by an Observable.

This means that calling subscribe is actually the moment when Observable starts its work, not when it is created, as it is often thought. Apart from starting the execution of an Observable, this method allows you to listen for values that an Observable emits, as well as for when it completes or errors.

You can achieve this in two following ways. The first way is creating an object that implements Observer interface.

It should have methods defined by that interface, but note that it should be just a regular JavaScript object, which you can create yourself in any way you want ES6 class, classic function constructor, object literal etc.

In particular do not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also that your object does not have to implement all methods. If you find yourself creating a method that doesn't do anything, you can simply omit it. Note however, that if error method is not provided, all errors will be left uncaught.

The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods. This means you can provide three functions as arguments to subscribe , where first function is equivalent of a next method, second of an error method and third of a complete method. Just as in case of Observer, if you do not need to listen for something, you can omit a function, preferably by passing undefined or null , since subscribe recognizes these functions by where they were placed in function call.

When it comes to error function, just as before, if not provided, errors emitted by an Observable will be thrown. Whatever style of calling subscribe you use, in both cases it returns a Subscription object. This object allows you to call unsubscribe on it, which in turn will stop work that an Observable does and will clean up all resources that an Observable used. Note that cancelling a subscription will not call complete callback provided to subscribe function, which is reserved for a regular completion signal that comes from an Observable.

Remember that callbacks provided to subscribe are not guaranteed to be called asynchronously. It is an Observable itself that decides when these functions will be called. For example of by default emits all its values synchronously. Always check documentation for how given Observable will behave when subscribed and if its default behavior can be modified with a Scheduler.

If no error handler is provided, the error will be thrown as unhandled. Flattens an Observable-of-Observables by dropping the previous inner Observable once a new one appears. Each time it observes one of these emitted inner Observables, the output Observable subscribes to the inner Observable and begins emitting the items emitted by that. However, when a new inner Observable is emitted, switch unsubscribes from the earlier-emitted inner Observable and subscribes to the new inner Observable and begins emitting items from it.

It continues to behave like this for subsequent inner Observables. An Observable that emits the items emitted by the Observable most recently emitted by the source Observable. Maps each value to an Observable, then flattens all of these inner Observables using switch. Each time it observes one of these inner Observables, the output Observable begins emitting the items emitted by that inner Observable. When a new inner Observable is emitted, switchMap stops emitting items from the earlier-emitted inner Observable and begins emitting items from the new one.

An Observable that emits the result of applying the projection function and the optional resultSelector to each item emitted by the source Observable and taking only the values from the most recently projected inner Observable. It's like switchMap , but maps each value always to the same inner Observable. The output Observables emits values only from the most recently emitted instance of innerObservable.

An Observable that emits items from the given innerObservable and optionally transformed through resultSelector every time a value is emitted on the source Observable, and taking only the values from the most recently projected inner Observable.

Takes the first count values from the source, then completes. If the source emits fewer than count values then all of its values are emitted. After that, it completes, regardless if the source completes. An Observable that emits only the first count values emitted by the source Observable, or all of the values from the source if the source emits fewer than count values.

Scheduler T Rx. Symbol observable. Test: Observable Observable. Static Method Summary Static Public Methods public static bindCallback func: function , selector: function , scheduler: Scheduler : function Converts a callback API to a function that returns an Observable. Converts a Node. Joins last values emitted by passed Observables. Creates an Observable that emits events of a specific type coming from the given event target. Converts a Promise to an Observable. Creates an Observable that emits no items to the Observer.

Creates an Observable that emits a sequence of numbers within a specified range. Wrapper around the w3c-compatible WebSocket object provided by the browser. Constructor Summary Public Constructor public constructor subscribe: Function. Buffers the source Observable values until closingNotifier emits. Buffers the source Observable values for a specific time period. Counts the number of emissions on the source and emits that number when the source completes.

Emits only the first value emitted by the source Observable that meets some condition. Projects each source value to an Observable which is merged in the output Observable. Re-emits all notifications from source Observable with specified scheduler. Groups pairs of consecutive emissions together and emits them as an array of two values. Used to stitch together functional operators into a chain.

Maps each source value an object to its specified nested property. Emits the most recently emitted value from the source Observable within periodic time intervals. Skip the last count values emitted by the source Observable. Asynchronously subscribes Observers to this Observable on the specified IScheduler. Emits only the first count values emitted by the source Observable. Emits only the last count values emitted by the source Observable.

Errors if Observable does not emit a value in given time span. Collects all source emissions and emits them as an array when the source completes. Static Public Methods public static bindCallback func: function , selector: function , scheduler: Scheduler : function Params: Name Type Attribute Description func function A function with a callback as the last parameter.

Return: function Receive an array of arguments passed to a callback. Use bindCallback with a selector function. Compare behaviour with and without async Scheduler. Use bindCallback on an object method. Test: Observable. See: bindNodeCallback from fromPromise. Example: Read a file from the filesystem and get the data as an Observable. Use on function calling callback with multiple arguments.

Use with selector function. Use on function calling callback in regular style. See: bindCallback from fromPromise. Return: Observable An Observable of projected values from the most recent values from each input Observable, or an array of the most recent values from each input Observable.

Example: Combine two timer Observables. Combine an array of Observables. Use project function to dynamically calculate the Body-Mass Index. See: combineAll merge withLatestFrom. Return: Observable All values of each passed Observable merged into a single Observable, in order, in serial fashion. Example: Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to Concatenate an array of 3 Observables.

Concatenate the same Observable to repeat it. See: concatAll concatMap concatMapTo. Create custom Observable, that does whatever you like. TypeScript signature issue Because Observable extends class which already has defined static create function, but with different type signature, it was impossible to assign proper signature to Observable.

Params: Name Type Attribute Description onSubscription function observer: Observer : TeardownLogic A function that accepts an Observer, and invokes its next , error , and complete methods as appropriate, and optionally returns some logic for cleaning up resources. Return: Observable An Observable that, whenever subscribed, will execute the specified function.

Example: Emit three numbers, then complete. Emit an error. Return unsubscribe function. See: empty never of throw. Return: Observable An Observable whose Observers' subscriptions trigger an invocation of the given Observable factory function. Example: Subscribe to either an Observable of clicks or an Observable of interval, at random.

See: create. Just emits 'complete', and nothing else. Return: Observable An "empty" Observable: emits only the complete notification. Example: Emit the number 7, then complete. Map and flatten only odd numbers to the sequence 'a', 'b', 'c'.

See: create never of throw. SubscribableOrPromise , project: function : Observable source Joins last values emitted by passed Observables. Params: Name Type Attribute Description sources SubscribableOrPromise Any number of Observables provided either as an array or as an arguments passed directly to the operator. Return: Observable Observable emitting either an array of last values emitted by passed Observables or value from project function. Example: Use forkJoin with operator emitting immediately.

Use forkJoin with operator emitting after some time. Use forkJoin with project function. See: combineLatest zip. Converts almost anything to an Observable. Example: Converts an array to an Observable. Convert an infinite iterable from a generator to an Observable. See: create fromEvent fromEventPattern fromPromise. Example: Emits clicks happening on the DOM document. Use addEventListener with capture option.

Params: Name Type Attribute Description addHandler function handler: Function : any A function that takes a handler function as argument and attaches it somehow to the actual source of events. See: from fromEvent. Example: Convert the Promise returned by Fetch to an Observable. See: bindCallback from. Emits incremental numbers periodically in time. Params: Name Type Attribute Description period number optional default: 0 The interval size in milliseconds by default or the time unit determined by the scheduler's clock.

Return: Observable An Observable that emits a sequential number each time interval. Example: Emits ascending numbers, one every second ms. See: timer delay. ObservableInput , concurrent: number , scheduler: Scheduler : Observable source Creates an output Observable which concurrently emits all values from every given input Observable.

Params: Name Type Attribute Description observables ObservableInput Input Observables to merge together. Return: Observable an Observable that emits items that are the result of every input Observable.

Example: Merge together two Observables: 1s interval and clicks. Merge together 3 Observables, but only 2 run concurrently. An Observable that never emits anything. Return: Observable A "never" Observable: never emits anything. Example: Emit the number 7, then never emit anything else not even complete. See: create empty of throw. Emits the arguments you provide, then completes. Params: Name Type Attribute Description values T Arguments that represent next values to be emitted.

Example: Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second. See: create empty never throw.

Emits a sequence of numbers in a range. Params: Name Type Attribute Description start number optional default: 0 The value of the first integer in the sequence. Return: Observable An Observable of numbers that emits a finite range of sequential integers. Example: Emits the numbers 1 to See: timer interval. Just emits 'error', and nothing else. Return: Observable An error Observable: emits only the error notification using the given error argument.

Example: Emit the number 7, then emit an error. Map and flatten numbers to the sequence 'a', 'b', 'c', but throw an error for See: create empty never of. Return: Observable An Observable that emits a 0 after the initialDelay and ever increasing numbers after each period of time thereafter.

Example: Emits ascending numbers, one every second ms , starting after 3 seconds. Emits one number after five seconds.

See: interval delay. Return: WebSocketSubject. Example: Wraps browser WebSocket. Wraps WebSocket from nodejs-websocket using node. Example: Combine age and name from different sources. Public Constructors public constructor subscribe: Function source Params: Name Type Attribute Description subscribe Function the function that is called when the Observable is initially subscribed to. Return: Observable this instance of the observable.

Params: Name Type Attribute Description durationSelector function value: T : SubscribableOrPromise A function that receives a value from the source Observable, for computing the silencing duration, returned as an Observable or a Promise.

Example: Emit clicks at a rate of at most one click per second. See: auditTime debounce delayWhen sample throttle. Params: Name Type Attribute Description duration number Time to wait before emitting the most recent source value, measured in milliseconds or the time unit determined internally by the optional scheduler. See: audit debounceTime delay sampleTime throttleTime. Example: On every click, emit array of most recent interval events.

See: bufferCount bufferTime bufferToggle bufferWhen window. Example: Emit the last two click events as an array. On every click, emit the last two click events as an array. See: buffer bufferTime bufferToggle bufferWhen pairwise windowCount.

Example: Every second, emit an array of the recent click events. Every 5 seconds, emit the click events from the next 2 seconds. See: buffer bufferCount bufferToggle bufferWhen windowTime. Example: Every other second, emit the click events from the next ms. See: buffer bufferCount bufferTime bufferWhen windowToggle. Params: Name Type Attribute Description closingSelector function : Observable A function that takes no arguments and returns an Observable that signals buffer closure.

Example: Emit an array of the last clicks every [] random seconds. See: buffer bufferCount bufferTime bufferToggle windowWhen. Params: Name Type Attribute Description selector function a function that takes as arguments err , which is the error, and caught , which is the source observable, in case you'd like to "retry" that observable by returning it again.

Return: Observable An observable that originates from either the source or the observable returned by the catch selector function. Example: Continues with a different Observable when there's an error. Retries the caught source Observable again in case of error, similar to retry operator. Throws a new error when the source Observable throws an error.

Once the outer Observable completes, it subscribes to all collected Observables and combines their values using the combineLatest strategy, such that: Every time an inner Observable emits, the output Observable emits. When the returned observable emits, it emits all of the latest values by: If a project function is provided, it is called with each recent value from each inner Observable in whatever order they arrived, and the result of the project function is what is emitted by the output Observable.

If there is no project function, an array of all of the most recent values is emitted by the output Observable. Params: Name Type Attribute Description project function optional An optional function to map the most recent values from each inner Observable into a new result. Return: Observable An Observable of projected results or arrays of recent values. Example: Map two click events to a finite interval Observable, then apply combineAll. See: combineLatest mergeAll.

Concatenate 3 Observables. Return: Observable An Observable emitting values from all the inner Observables concatenated. Example: For each click event, tick every second from 0 to 3, with no concurrency. The arguments passed to this function are: outerValue : the value that came from the source innerValue : the value that came from the projected Observable outerIndex : the "index" of the value that came from the source innerIndex : the "index" of the value from the projected Observable.

Return: Observable An Observable that emits the result of applying the projection function and the optional resultSelector to each item emitted by the source Observable and taking values from each projected inner Observable sequentially. Return: Observable An observable of values merged together by joining the passed observable with itself, one after the other, for each value emitted from the source.

Tells how many values were emitted, when the source completes. It is provided with arguments of: value : the value from the source Observable. Return: Observable An Observable of one number that represents the count as described above. Example: Counts how many seconds have passed before the first click happened. Counts how many odd numbers are there between 1 and 7. See: max min reduce.



0コメント

  • 1000 / 1000