Repository navigation
Replies: 1 comment 4 replies
|
Good news first: the built-in slider binder already doesn’t notify the ViewModel when it sets the value. In SliderValueMonoBinder.SetValue the write is wrapped in an _isNotifyValueChanged = false guard, and in OneWay/OneTime mode the binder never even subscribes to onValueChanged. So nothing echoes back to the VM. What does happen is that slider.value = … raises Slider.onValueChanged for other listeners (your own scripts, UnityEvents in the inspector). That’s documented in the binder’s remarks. If those are what you want to keep quiet, you don’t need to subclass the control: a small custom binder using SetValueWithoutNotify is enough. csharp [BindModeOverride(IsOne = true)] // OneWay / OneTime only } A Notify = false option on the stock binders would be a nice built-in. If you want it upstream, it’s worth opening as a feature request. If this helps, please mark it as the answer. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'm using Aspid.MVVM in my project (https://github.com/Trigve/Ja2xUnity) and I've came across the situation, when I have a value binder (OneTime or OneWay which is used for initial value initialization or value reset without "callbacks" back to the VM). Now, in some situation I need to set the value on the target but WITHOUT notification. For instance, uGUI
Sliderdoes haveSetValueWithoutNotify()which could be used, but binder are always setting the value directly using property (which will emit the event). So the solutions now are hacky (inheriting control, various additional components, ...).The one option I see is to add additional attribute parameter to the binder, like for instance
OneTimeBind(Notify = false)]. Or is there any other clean solution?All reactions