Missing "UserPatch" mentioned in the documentation

Hey there! I am reading the documentation about Custom Regions and it states under “Stateful - get your hands dirty”:

Search for UserPatch . You’ll find a helper patch that allowed to declare some stateful region. Take this as an example for now.

I’ve searched in the help and node browser as well in the gray book, but can not find it… :(

https://thegraybook.vvvv.org/reference/extending/custom-regions.html

Actually I just found something about it in the chat, when @sebescudie asked the same thing in March 2023.

The answer from @gregsn:

sorry for that. Plan is: We’ll provide a help patch for that. For now please look at how LayerWidget region is patched:

the file can be accessed like this:

It shows how to type delegate-based inputs in such a way that the compiler offers the user of the node to create it as a stateful region.

One of the main ideas here is that the state is created and updated explicitly. And the region could make use of those delegates that describe state creation and update in any you want. (Region could potentially internally store several states and manage the lifetime of them).

The delegates get built by the compiler in cooperation with the end user. The End-user patches something inside the region. The Compiler turns the white parts into one delegate and the grey parts into another delegate.

Now the region developer needs to call those create- and update-delegates whenever this makes sense. And should also try to dispose of that state whenever the lifetime of a particular state is over.

UserPatch is just a very basic implementation, which takes care of one region state instance. You now can try to use this UserPatch process node inside your region in order to avoid all those details and think on a higher level, or you could try to make sense of this patch and apply what you learned inside your region implementation without using this modularization.

you’ll find quite some other examples on how to use it in LayerX, Elementa (LayerWidget), if this helps as you might be more familiar with those node sets

But maybe add an example to the Help Browser to avoid confusion here.

2 Likes