Open davidbonnet opened 7 years ago
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.
I find $destroy
nicer.
I was under Swift influence with $deinit
, but $destroy
is indeed better. Thanks to the prefix, we could even use $delete
.
Might want to reserver $delete for something later on.
$destroy +1
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?