Lawo / ember-plus-sharp

Quickly implement fully type-safe Ember+ consumers in any .NET language
http://lawo.github.io/ember-plus-sharp
Boost Software License 1.0
21 stars 12 forks source link

How to react multiple Changes #62

Open marcoferre opened 3 years ago

marcoferre commented 3 years ago

Hi,

I need to wait continuosly new Reaction on Changes of a node that i'm inspecting.

With the code in the documentation:

var valueChanged = new TaskCompletionSource<string>();
positionParameter.PropertyChanged += (s, e) => valueChanged.SetResult(((IElement)s).GetPath());

Console.WriteLine("Waiting for the parameter to change...");
Console.WriteLine("A value of the element with the path {0} has been changed.", await valueChanged.Task);

is possible to wait and listen only the first change.

My request to help deal with the possibility to listen all the changes of a node (ie: every time a FaderPosition change, update a view with the value). How can I do That?

Thanks a lot

sronline commented 3 years ago

you can create multiple listeners:

var valueChanged = new TaskCompletionSource(); positionParameter.PropertyChanged += (s, e) => valueChanged.SetResult(((IElement)s).GetPath()); otherParameter.PropertyChanged += (s, e) => valueChanged.SetResult(((IElement)s).GetPath());`

Console.WriteLine("Waiting for the parameter to change..."); Console.WriteLine("A value of the element with the path {0} has been changed.", await valueChanged.Task);`

sronline commented 3 years ago

But if multiple changes are done at the same time information is lost