Reputation: 77
Understanding that observables are not enumerables, and visa versa:
Using ReactiveUI, what are the recommended ways to wrap an IEnumerable<T>
with an IObservable<T>
?
For instance, given the values
variable below, how could an observable be created that generates an action for each element?
var values = new int[] { 0, 1, 2, 3 };
Upvotes: 0
Views: 323
Reputation: 1299
values.ToObservable()
will create an Observable based on your IEnumerable
, in which you can then project each item using Select()
.
Also note that if you need your Observable to then return all your items into an IObservable<IEnumerable<T>>
, you can buffer the list:
values.
.ToObservable()
.Select(x => ...)
.Buffer(values.Count)
Upvotes: 1