ui: Expands create-listeners API to allow recursive addition and plain function addition #5616
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR expands/improves upon the `create-listeners' utility which we added in #4859
Listeners
class.Listeners
recursively. So you cancreateListeners().add(createListeners())
(or using the Mixinthis.listen(somethingThatReturnsListeners()
).add
as a plain function as a teardown functionThis moves the entire idea more towards a generic teardown utility, potentially at some point in the future this could be renamed to reflect that.
Additionally, using the function that is returned from
add
ing a listener to tear it back down again wouldn't clean up the function from the internallisteners
array meaning that this array could potentially grow unnecessarily. We aren't using this functionality anywhere currently but this functionality now cleans up correctly incase we ever do (also see removed comments)To note: All of this functionality is now 'inherited' by the
WithListeners
Mixin which is basically an ember specific wrapper tocreate-listeners
Lastly we aren't using any of this extra functionality as yet (but will be), but we've added some additional tests here.