Skip to content

refactor(autocomplete): make keyboard and visibility calls synchronous #6441

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

Merged
merged 4 commits into from
Oct 3, 2017

Conversation

crisbeto
Copy link
Member

Reworks a few methods, that were changing the view in a Promise.resolve, to be synchronous. The initial idea behind deferring those calls was to avoid "changed after checked" errors, however they also make things harder to test. It seems like the root of the issue for all of them was that we were trying to modify view properties after the options.changed callback had fired, which comes after change detection. These changes have the advantage of making things a lot easier and cleaner to test, as well as making the API easier to use.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 13, 2017

// Defer emitting to the stream until the next tick, because changing
// bindings in here will cause "changed after checked" errors.
return Promise.resolve();
Copy link
Contributor

Choose a reason for hiding this comment

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

Mixing switchMap and Promise.resolve doesn't feel quite right. Use do and observeOn(asap) operators here instead? It would be more rx idiomatic.

@kara kara assigned crisbeto and unassigned kara Aug 16, 2017
@crisbeto crisbeto force-pushed the autocomplete-promise-refactor branch 2 times, most recently from 5da9ee7 to de700f1 Compare August 20, 2017 11:11
@crisbeto
Copy link
Member Author

@kara I've switch it to use delay instead of switchMap. Can you take another look?

@crisbeto crisbeto assigned kara and unassigned crisbeto Aug 20, 2017
@crisbeto crisbeto force-pushed the autocomplete-promise-refactor branch from de700f1 to 0d94a6b Compare August 28, 2017 18:14
@crisbeto crisbeto force-pushed the autocomplete-promise-refactor branch from 0d94a6b to 02bbe0e Compare September 4, 2017 19:16
@crisbeto crisbeto added the P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful label Sep 14, 2017
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM, will need rebase.

@kara kara assigned crisbeto and unassigned kara Sep 20, 2017
@crisbeto crisbeto force-pushed the autocomplete-promise-refactor branch from 02bbe0e to e0ea08e Compare September 20, 2017 21:11
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Sep 20, 2017
@crisbeto crisbeto force-pushed the autocomplete-promise-refactor branch 2 times, most recently from fa2f980 to 37a0d19 Compare September 30, 2017 09:27
@kara
Copy link
Contributor

kara commented Oct 2, 2017

@crisbeto Looks like a linter failure bc map is unused. Update?

@kara kara removed the action: merge The PR is ready for merge by the caretaker label Oct 2, 2017
@crisbeto crisbeto force-pushed the autocomplete-promise-refactor branch from 37a0d19 to f13b84e Compare October 3, 2017 15:02
@crisbeto
Copy link
Member Author

crisbeto commented Oct 3, 2017

Fixed the linting error and a test failure.

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker labels Oct 3, 2017
Reworks a few methods, that were changing the view in a `Promise.resolve`, to be synchronous. The initial idea behind deferring those calls was to avoid "changed after checked" errors, however they also make things harder to test. It seems like the root of the issue for all of them was that we were trying to modify view properties after the `options.changed` callback had fired, which comes after change detection. These changes have the advantage of making things a lot easier and cleaner to test, as well as making the API easier to use.
@crisbeto crisbeto force-pushed the autocomplete-promise-refactor branch from f13b84e to ff41770 Compare October 3, 2017 17:25
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Oct 3, 2017
@kara kara merged commit 36da4c3 into angular:master Oct 3, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants