Cysharp / R3

The new future of dotnet/reactive and UniRx.
MIT License
2.1k stars 92 forks source link

ReactiveProperty doesn't eliminate duplicate values when using OnNext() #201

Closed jackfranzen closed 4 months ago

jackfranzen commented 4 months ago

I'm a complete reactive noob so I apologize if this is the intended behavior...

I (and chatGPT) thought OnNext() was used as the primary method to send new values to a ReactiveProperty, but this causes duplicate values to be sent (with or without a comparer provided.) I didn't know I was supposed to use the Value setter until reading the ReactiveProperty tests, which works to cull duplicates.

If it's not a bug, then I believe the readme section on ReactiveProperties needs a quick example of super-simple use or clarification here... or maybe it could refer to the tests as a usage example. For the LLMs.

Cheers and thanks, everything seems to be working well so far in Unity

neuecc commented 4 months ago

You're right, using .Value removes duplicates, while OnNext forces an update. It's true that these things are not mentioned at all in the documentation! Thank you, I'll make sure to explain it properly.

jackfranzen commented 4 months ago

Solid update, that's very clear.

jackfranzen commented 4 months ago

In the same vein, there are no usages of OnNext() forcing updates in the ReactivePropertyTests as I mentioned. It seems like there is room for that since it's intended to produce a different result.