[SOLVED] Shutting down observables

hello,
i fighting with observables a little.
I create an instrument and then a sample.
I connect notifiers /I could handle it/ but how do I disconnect it all when I close the tool ?
Checking for tool.visible in tool.app_idle_observable ?
if tool is not visible then remove notifiers ?

which way is the right one ?
thanks

That sounds about right, to my recollection.

You can create a ā€œglobalā€ table (or even better some class, if you wanna go that route) where you store used observables and their functions. Then itā€™s easy to just iterate and unobserve whatever has been added without keeping track of stuff manually.

itā€™s still not a little clear to me how the tool actually behaves.
the first start is clear, but after the subsequent ā€œendā€ so the tool window is not visible, it seems to me that the tool is just moved to the background but still running.
After the subsequent call from the menu, the start-up procedure is the same as the first time or different. it seems to me that its global variables still contain values when hidden.

Enabled tools are always running. (The GUI is not the tool. Lots of tools have no GUI.)

ty,
i want use something like you in this post
here

seems to be very usefull for bunch of observers

Ah. That one can be used if you just want to make a :bang() to run several functions at once. Maybe not quite the same.

But if you find yourself using a lot of observables/functions that you know you want to easily destroy at once (at gui close), itā€™s not a bad idea to just store them in a global table. tbl[1] = { obs = theobservable, func = regged_function }. Then itā€™s easy to destroy them all at once with a table iteration. (PS. donā€™t forget removing the destroyed element from this table)

In larger projects, I like being able to keep track of used observables anyway, with some simple rprint ā€˜debuggingā€™.

ok,
thanks for your patience. Iā€™ll try it

1 Like

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