emit a specified sequence of items before beginning to emit the items from the source Observable
If you want an Observable to emit a specific sequence of items before it begins emitting the items normally expected from it, apply the StartWith operator to it.
(If, on the other hand, you want to append a sequence of items to the end of those normally emitted by an Observable, you want the Concat operator.)
cons
RxClojure implements this operator as cons
. It takes an item and an Observable as parameters, and prepends the item to the items emitted by the Observable as its own Observable sequence.
start_with
RxCpp implements this operator as start_with
. It takes an Observable and one or more items as parameters, and prepends these items, in the order they are given in the parameter list, to the items emitted by the Observable as its own Observable sequence.
startWith
RxGroovy implements this operator as startWith
.
You can pass the values you want to prepend to the Observable sequence to startWith
either in a single Iterable or as a series of one to nine function parameters.
def myObservable = Observable.from([1, 2, 3]); myObservable.startWith(-3, -2, -1, 0).subscribe( { println(it); }, // onNext { println("Error: " + it.getMessage()); }, // onError { println("Sequence complete"); } // onCompleted );
startWith(Iterable)
startWith(T)
(there are also versions that take up to nine individual items) You can also pass startWith
an Observable, and it will prepend the emissions from that Observable to those of the source Observable to make its own set of emissions. This is a sort of inverted Concat operation.
startWith(Observable)
startWith
RxJava implements this operator as startWith
.
You can pass the values you want to prepend to the Observable sequence to startWith
either in a single Iterable or as a series of one to nine function parameters.
startWith(Iterable)
startWith(T)
(there are also versions that take up to nine individual items) You can also pass startWith
an Observable, and it will prepend the emissions from that Observable to those of the source Observable to make its own set of emissions. This is a sort of inverted Concat operation.
startWith(Observable)
startWith
RxJS implements this operator as startWith
. It accepts a variable number of function parameters and treats each one as an item that it will prepend to the resulting Observable sequence in the order they are given in the parameter list.
startWith
is found in the following distributions:
rx.js
rx.all.js
rx.all.compat.js
rx.compat.js
rx.lite.js
rx.lite.compat.js
startWith
RxKotlin implements this operator as startWith
.
You can pass the values you want to prepend to the Observable sequence to startWith
either in a single Iterable or as a series of one to nine function parameters.
You can also pass startWith
an Observable, and it will prepend the emissions from that Observable to those of the source Observable to make its own set of emissions. This is a sort of inverted Concat operation.
StartWith
Rx.NET implements this operator as StartWith
. It accepts an array of items which it prepends to the resulting Observable sequence in the order they appear in the array before it emits the items from the source Observable.
startWith startWithArray
RxPHP implements this operator as startWith
.
Prepends a value to an observable sequence with an argument of a signal value to prepend.
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/startWith/startWith.php $source = \Rx\Observable::of(2) ->startWith(1); $subscription = $source->subscribe($stdoutObserver);
RxPHP also has an operator startWithArray
.
Prepends a sequence of values to an observable sequence with an argument of an array of values to prepend.
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/startWith/startWithArray.php $source = \Rx\Observable::of(4) ->startWithArray([1, 2, 3]); $subscription = $source->subscribe($stdoutObserver);
start_with
RxPY implements this operator as start_with
. It accepts an array of items which it prepends to the resulting Observable sequence in the order they appear in the array before it emits the items from the source Observable.
start_with
Rx.rb implements this operator as start_with
. It accepts an array of items which it prepends to the resulting Observable sequence in the order they appear in the array before it emits the items from the source Observable.
+:
RxScala implements this operator with +:
It takes an item and an Observable as parameters, and prepends the item to the items emitted by the Observable as its own Observable sequence.
© ReactiveX contributors
Licensed under the Apache License 2.0.
http://reactivex.io/documentation/operators/startwith.html