Beginning RxSwift - Part 4: Creating | Ray Wenderlich Videos

Go over several operators you can use to create observables from individual values and collections of values.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4743-beginning-rxswift/lessons/4

Hi!
Since prequelTrilogy is just one object (one array of Strings), couldn’t we use Observable.just([episodeI, episodeII])?

@scotteg Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @carolbonturi, yes, you could use either operator here. Great observation! What I am pointing out here is, the just operator can only take a single value, whereas the of operator can take a varying number of elements — i.e., it’s a variadic parameter. So if you pass a single value that is an array of values to of, that single array will be emitted all at once. However, if you pass those same values individually, each of those values will be emitted sequentially. That’s why I went with using of for originalTrilogy and prequelTrilogy, to demonstrate the difference.