Just
create an Observable that emits a particular item
See Also
- From
- Repeat
- Start
- Timer
- Introduction to Rx: Return
- RxJava Tutorial 03: Observable from, just, & create methods
Language-Specific Information
RxGroovy just
RxJava 1․x just
RxJS just return
RxPHP of
RxSwift just sequenceOf
In Swift, this is implemented using the Observable.just
class method.
The parameter, whether a tuple (i.e. (1, 2, 3)
) or an array (i.e. [1,2,3]
) is produced as one emission.
Sample Code
let source = Observable.just(1, 2, 3) source.subscribe { print($0) } let source2 = Observable.just([1,2,3]) source2.subscribe { print($0) }
next((1, 2, 3)) completed next([1, 2, 3]) completed
The difference between this and Observable.from
is that the latter's parameter is an array or a sequence, and emits each of its element as one emission.
© ReactiveX contributors
Licensed under the Apache License 2.0.
http://reactivex.io/documentation/operators/just.html