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

core(user-flow): start/end navigation functions #13966

Merged
merged 15 commits into from
Jun 14, 2022
Merged

Conversation

adamraine
Copy link
Member

We previously discussed this idea 🔒 here. Using some promise/callback BS we can implement both the callback approach and start/end approach for user triggered navigations.

@adamraine adamraine changed the title core(user-flow): separate start/end navigation functions core(user-flow): separate start/end navigation functions + replay script May 6, 2022
@adamraine adamraine changed the title core(user-flow): separate start/end navigation functions + replay script core(user-flow): separate start/end navigation functions May 19, 2022
@adamraine adamraine changed the title core(user-flow): separate start/end navigation functions core(user-flow): start/end navigation functions May 19, 2022
@adamraine adamraine marked this pull request as ready for review May 19, 2022 23:09
@adamraine adamraine requested a review from a team as a code owner May 19, 2022 23:09
@adamraine adamraine requested review from connorjclark and removed request for a team May 19, 2022 23:09
Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

+1, but docs?

@adamraine
Copy link
Member Author

Yeah docs sound good. @paulirish is #14021 ready to go first?

Also, just had an idea. We could add a new smoke test runner for this. I'll do it in a separate PR.

*/
async startNavigation(stepOptions) {
/** @type {ExternalPromise<() => void>} */
const setupPromise = new ExternalPromise();
Copy link
Member

Choose a reason for hiding this comment

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

why can't this just be a promise? looking at the extpromise impl i'm not seeing what's special about it…

Copy link
Member

@paulirish paulirish Jun 13, 2022

Choose a reason for hiding this comment

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

There's a pattern that the playwright guys used to do (and still do).. and i think it'd achieve what you're going for here…

    let fulfill = () => {};
    let reject = () => {};
    const result = new Promise((res, rej) => { fulfill = res; reject = rej; });

    // …
    fulfill(continueNav)

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's not any different. It's just encapsulated. I like it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a big amount of indirection here that takes a moment to figure out. I tried to help in my comment suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

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

The main goal was to make the code easier to read by reducing the nested promises and such. It was a generic pattern that we might user later, but that's just wishful thinking I guess.

I'm fine going with paul's suggestion here.

lighthouse-core/fraggle-rock/user-flow.js Outdated Show resolved Hide resolved
lighthouse-core/fraggle-rock/user-flow.js Outdated Show resolved Hide resolved
lighthouse-core/fraggle-rock/user-flow.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants