Using Observable.just()
In our previous example with Observable.create(), we could have used Observable.just() instead and accomplished the same effect. It is likely that you will not need to use the Observable.create() factory often. Certain non-reactive sources can be helpful too, and we will see them in a couple of places later in this chapter. But typically, we use streamlined factories to create an Observable object: see Observable.just() described in this section and other factories in the following Other Observable sources section.
We can pass into the just() method up to 10 items that we want to emit. This will invoke onNext() for each one and then invoke onComplete() when they have all been pushed. Look at the following code block ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access