TogEdge exhibiting surprising behaviour when inside an Update method

When placed inside an Update method, TogEdge seems to become stateless:

  • UpEdge fires as long the input is true
  • DownEdge never fires

A patch that demonstrates this can be found here:
http://schlimme-gegend.de/whoopwhoop/VL_TogEdge_Test.7z
(Would have attached the file if my account wasn’t too new)

hi, this seems to be a misunderstanding on how patches work in VL compared to patches in vvvv.
in your second example the TogEdge and its state becomes part of the state of your own data type:

so in order to preserve the state of the TogEdge you need to preserve the state of an instance of your data type. either by also using an implicit instance via a process node:

or by managing an instance (hence the state) of your type on your own:

which in this concrete example does exactly the same as the process node but explicitly.

some more details if you are interested:
your data type is set to Class, so a link of that type only transports a reference from pin to pin. this means that in the above example you don’t actually need to write something back to the MyInstance property, because the Update will update the one instance stored in the property.

this can lead to bugs if you have many operations that modify (mutate) its state because the order of execution becomes important.

anyway, this works too:

if you set your data type to the recommended Record. Then the links actually transport the whole instance from pin to pin and you get a new modified instance after each operation that modifies the instance, Update in this case. This makes data flow patching much simpler because order doesn’t matter.

in that case however you need to store the new instance that comes out of Update back to the property in order to get it back in the next frame:

2 Likes

Thank you a lot, this really clarified things. I have rebuilt your demos and combined them with some annotation in this patch, whis is intended to be a tutorial for the stuff discussed here:
http://schlimme-gegend.de/whoopwhoop/VL_ClassesStatesRecords_Demo.7z

1 Like

thanks for the explanations in the patch. here is a re-upload in case it gets deleted from your server:
VL_ClassesStatesRecords_Demo.zip (15.1 KB)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.