-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Description
getTriggerFlow essentially only fires an event for the first time that the time the trigger property is triggered.
StateFlow<Unit> isn't great for this. Namely because Unit has a singular instance, all values emitted will be considered equal, and there will be now downstream events. SharedFlow<Unit> does not have this same problem.
It may also be worth while to consider using SharedFlows for the other property flows as well, as you may actually need the insights to when something got a new, but otherwise equivalent value. If users need to ensure that repeated equivalent values are ignored, then they can choose to do so with distinctUntilChanged (or provide an optional areEquivalent: (old: T, new: T) -> Boolean parameter that defaults to using == and internally using distinctUntilChanged)
I suppose the biggest hurdle for the non-trigger properties would be the fact that SharedFlow doesn't have a .value that you can use to grab the value at any time, otherwise, SharedFlow can be created in such a way that it is equivalent to StateFlow for everything except filtering equivalent values.
Provide a Repro
Load up a rive file that has a trigger property that will be triggered multiple times, try to count the number of times it is triggered.
Expected behavior
I'd expect to be able to listen to every time that the property is triggered.
Device & Versions (please complete the following information)
- Rive 10.4.2