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

Remove simple alias for wait -> settled. #317

Merged
merged 1 commit into from
Feb 10, 2018

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Feb 10, 2018

The original goal of settled was to "rebrand" wait as settled without the 'baggage" (since wait had some legacy APIs that should not exist in settled). Unfortunately, the code refactoring that I had originally done that allowed them to be shared resulted in introducing bugs like those reported in #283.

This commit completely severs the implementation of wait from that of settled, by leveraging the (IMHO very nice) layers of abstraction that we have created since the original extraction. Implementing wait with waitUntil and getSettledState makes this quite trivial now.

tldr of changes:

  • isSettled no longer has to support the legacy wait contract (this was undocumented private behavior only kept around to support the old semantics of wait)
  • wait is implemented as its own waitUntil with the same semantics it has had since the 0.6.x series

Fixes #300
Fixes #283
Closes #303

@deprecated
@returns {Promise<void>} resolves when settled
*/
export default function settled() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be called wait(), not settled()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOH! Indeed!

@returns {Promise<void>} resolves when settled
*/
export default function settled() {
let options = arguments[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use function wait(options = {}) { instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk, seems good

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, actually its a tad different. The old 0.6.x wait code avoided errors when something like a number was passed in, if I use default arguments here it will only correct for undefined specifically...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, the logic to handle non-objects would likely still need to exists, but I think putting options = {} in would still be good for documentation purposes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

The original goal of `settled` was to "rebrand" `wait` as `settled` without the
'baggage" (since `wait` had some legacy APIs that should not exist in
`settled`). Unfortunately, the code refactoring that I had originally done that
allowed them to be shared resulted in introducing bugs like those
reported.

This commit completely severs the implementation of `wait` from that of
`settled`, by leveraging the (IMHO very nice) layers of abstraction that we
have created since the original extraction.  Implementing `wait` with
`waitUntil` and `getSettledState` makes this quite trivial now.

tldr of changes:

* `isSettled` no longer has to support the legacy `wait` contract (this was
  undocumented private behavior _only_ kept around to support the old semantics
  of `wait`)
* `wait` is implemented as its own `waitUntil` with the same
  semantics it has had since the 0.6.x series
@rwjblue rwjblue merged commit f381a9c into emberjs:master Feb 10, 2018
@rwjblue rwjblue deleted the alternative-suggestion branch February 10, 2018 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants