-
Notifications
You must be signed in to change notification settings - Fork 8
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
Callback when a model goes out of use. #59
Comments
Will it be like "Suspendable" i.e. can be deactivated/reactivated repeatedly? |
In react hook there is @:effect function subscribe():CallbackLink; this would track observables used in the function and re-call when necessary. |
Not sure I follow 100%. Can you please elaborate on how this would be used? |
Roughly something like this: @:observable var id:String;
@:editable var currentValue:Int;
@:effect function subscribe():CallbackLink {
// when `id` changes, this function will be called again, the last CallbackLink produced will be dissolved at the same time
return subscribeForExternalChange(id, value -> currentValue = value);
} @:effect is a function that will produce side effects, and returns a callback link to undo it, and when the model goes out of use, the callback link will be called to cleanup resources. maybe it is just equivalent to |
I am interested in implementing this, are there any tips where I should get started? |
It should be possible to detect when none of a model's observable/editable properties are in use and so that any underlying subscriptions (to a websocket or something) can be cleaned up.
The text was updated successfully, but these errors were encountered: