Processes inside a class with boolean pins eg FileReader FileWriter

In the element chat @karistouf had a question about putting the stateful read and write processes inside a class where they are called as part of a class.read() or class.write() function.

I thought also to document the answer here to make it easy to search in future.


So by convention things on Update (grey operation) are running every frame. But once you deal with classes and their methods Update isn’t automatically running every frame. Only if you create a method called Update and ensure YourClass.Update() is literally running every frame.

When you see basic control flow in vvvv intended to run on update in helppatches then it will have bangs etc to trigger one frame actions. Often attached to if blocks or to stateful processes like FileReaders and FileWriters. You can use these processes inside classes but what happens to the booleans?

If you encapsulate that control flow in the method of a class (class.Read()) then you can just trigger that function once.

But you have to ensure any internal booleans are in the correct state for being triggered once. So probably high for processes like file reader etc.

Demo patch here
ReadWriteSomethingFromAClass.vl (28.4 KB)

There is more info on running stateful processes inside classes in my class manipulation and mutability tutorials

Keywords: Serialisation, Serialiszation, XMLReader, XMLWriter, XML, Save, Load

2 Likes