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

Destructor #118

Open
davidbonnet opened this issue Jun 24, 2017 · 5 comments
Open

Destructor #118

davidbonnet opened this issue Jun 24, 2017 · 5 comments

Comments

@davidbonnet
Copy link

davidbonnet commented Jun 24, 2017

Motivation

Components currently support the $init callback that fires when the element is generated for the first time. This enables construction logic such as enabling a specific behaviour, issuing an API call or, as outlined here, subscribing to an observable.

However, the lifetime of an element might come to an end, typically due to a user action (e.g., closing a widget which removes a bunch of elements). In this case, it becomes necessary to terminate all ongoing transactions created by this element, such as cancelling API calls or unsubscribing from an observable. Such logic typically resides in a destructor callback, which could be called $deinit.

What about adding such callback? Or what would be the alternatives?

@gliechtenstein
Copy link
Contributor

This is a great idea, thanks for bringing it up.

$deinit is nice but how about $destroy? Or if anyone has another suggestion, please feel free to share.

@piranna
Copy link

piranna commented Jun 25, 2017

I find $destroy nicer.

@davidbonnet
Copy link
Author

davidbonnet commented Jun 25, 2017

I was under Swift influence with $deinit, but $destroy is indeed better. Thanks to the prefix, we could even use $delete.

@idkjs
Copy link

idkjs commented Jun 27, 2017

Might want to reserver $delete for something later on.

@ghost
Copy link

ghost commented Jun 28, 2017

$destroy +1

@ghost ghost mentioned this issue Jul 1, 2017
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

4 participants