Skip to content

Conversation

@adamraine
Copy link
Contributor

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 force-pushed the start-end-navigation branch from eb020e8 to f81be39 Compare May 19, 2022 22:07
@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
Contributor 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
Contributor 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.

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