Skip to content

Creating source node which sends new event when a property is changed #1781

Answered by ncguilbeault
ZegCricket asked this question in Q&A
Discussion options

You must be logged in to vote

I think the Bonsai source code has some examples for how to do this. For example, here.

Basically, in addition to what you have already coded, you want to trigger an event that will emit a new value to the sequence whenever the property value changes. In the example above, there is a function called OnValueChanged which gets called anytime the value of the property is set. The Action<int> ValueChanged is a type of delegate, which takes a single argument int. The OnValueChanged method is responsible for raising the ValueChanged event.

Inside of the Generate method, Observable.Defer(() => Observable.Return(value)) ensures that the current value is emitted when the observable sequence is sub…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ZegCricket
Comment options

Answer selected by ZegCricket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants