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

ui: Expands create-listeners API to allow recursive addition and plain function addition #5616

Merged
merged 1 commit into from
May 15, 2019

Conversation

johncowen
Copy link
Contributor

This PR expands/improves upon the `create-listeners' utility which we added in #4859

  1. Adds a Listeners class.
  2. Point 1 lets us then add Listeners recursively. So you can createListeners().add(createListeners()) (or using the Mixin this.listen(somethingThatReturnsListeners())
  3. Also add the ability to .add as a plain function as a teardown function

This 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 adding a listener to tear it back down again wouldn't clean up the function from the internal listeners 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 to create-listeners

Lastly we aren't using any of this extra functionality as yet (but will be), but we've added some additional tests here.

@johncowen johncowen changed the title ui: Expands create-listeners API to allow recursive addition and plain functions ui: Expands create-listeners API to allow recursive addition and plain function addition Apr 8, 2019
@johncowen johncowen added the theme/ui Anything related to the UI label Apr 8, 2019
@johncowen johncowen requested a review from a team April 8, 2019 14:14
@johncowen johncowen force-pushed the feature/ui-create-listener-improvements branch from 34c558c to fd217ed Compare April 29, 2019 11:30
@johncowen johncowen added this to the Upcoming milestone Apr 29, 2019
@johncowen johncowen force-pushed the ui-staging branch 2 times, most recently from 60bac11 to 9994267 Compare May 2, 2019 18:29
1. Adds a Listeners class, which lets us...
2. Add Listeners recursively. So you can
createListeners().add(createListeners())
3. Also add the ability to `.add` as a plain function

This moves the entire idea more towards a generic teardown utility
@johncowen johncowen force-pushed the feature/ui-create-listener-improvements branch from fd217ed to 6d1914a Compare May 15, 2019 13:15
@johncowen johncowen merged commit 4dd9fd5 into ui-staging May 15, 2019
@johncowen johncowen deleted the feature/ui-create-listener-improvements branch May 15, 2019 13:21
johncowen added a commit that referenced this pull request May 24, 2019
)

1. Adds a Listeners class, which lets us...
2. Add Listeners recursively. So you can
createListeners().add(createListeners())
3. Also add the ability to `.add` as a plain function

This moves the entire idea more towards a generic teardown utility
johncowen added a commit that referenced this pull request Jun 21, 2019
)

1. Adds a Listeners class, which lets us...
2. Add Listeners recursively. So you can
createListeners().add(createListeners())
3. Also add the ability to `.add` as a plain function

This moves the entire idea more towards a generic teardown utility
johncowen added a commit that referenced this pull request Aug 22, 2019
)

1. Adds a Listeners class, which lets us...
2. Add Listeners recursively. So you can
createListeners().add(createListeners())
3. Also add the ability to `.add` as a plain function

This moves the entire idea more towards a generic teardown utility
johncowen added a commit that referenced this pull request Aug 29, 2019
)

1. Adds a Listeners class, which lets us...
2. Add Listeners recursively. So you can
createListeners().add(createListeners())
3. Also add the ability to `.add` as a plain function

This moves the entire idea more towards a generic teardown utility
johncowen added a commit that referenced this pull request Sep 4, 2019
)

1. Adds a Listeners class, which lets us...
2. Add Listeners recursively. So you can
createListeners().add(createListeners())
3. Also add the ability to `.add` as a plain function

This moves the entire idea more towards a generic teardown utility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants