neuecc / UniRx

Reactive Extensions for Unity
MIT License
7.01k stars 895 forks source link

ReactiveCollection: Why ForEach doesn't exist. #486

Open victormarllam opened 3 years ago

victormarllam commented 3 years ago

Is there any technical reason about ReactiveCollection doesn't contain ForEach with lambda expression?

I see that ReactiveCollection implements the following interfaces Collection<T>, IReactiveCollection<T>, IDisposable.

In which one ForEach should be declared?

Thaina commented 3 years ago

As of ReactiveX, ForEach of RX system is not for the collection itself but for the Observable

Which, the collection are providing observable that you could ForEach on it, like ObserveAdd or ObserveReplace but the IReactiveCollection itself is not inherit from IObservable

If you want to use ForEach on collection directly, you need to use other library that extend ForEach for IEnumerable