Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the number of listeners to a Variable #71

Open
karlak opened this issue Jun 14, 2021 · 1 comment
Open

Getting the number of listeners to a Variable #71

karlak opened this issue Jun 14, 2021 · 1 comment

Comments

@karlak
Copy link

karlak commented Jun 14, 2021

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 ?

@kriszyp
Copy link
Owner

kriszyp commented Jun 16, 2021

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants