alkali icon indicating copy to clipboard operation
alkali copied to clipboard

Getting the number of listeners to a Variable

Open karlak opened this issue 4 years ago • 1 comments

Hello, first thank you for all your work on this, hopping this isn't a dumb question.

I'd like to know if a variable has any listeners, or dependent variable using its value, but can't find anything about it or in the variable object. Is there any relatively fast way to do this ?

karlak avatar Jun 14 '21 23:06 karlak

You should be able to just check the listeners property of the variable. It will be false if there are no listeners, otherwise it will have an array of listeners. Note this is only for "active" listeners, that is dependent variables that are actively receiving notification of changes. If another dependent variable is using this variable, but is not active (no listeners itself), then there is no reference to the dependent variable (because that would break garbage collection).

kriszyp avatar Jun 16 '21 13:06 kriszyp