Skip to content

wip: allow show() to take optional promise - #668

Closed
marcoscaceres wants to merge 7 commits into
gh-pagesfrom
show_optional_promise
Closed

marcoscaceres wants to merge 7 commits into
gh-pagesfrom
show_optional_promise

Conversation

@marcoscaceres

@marcoscaceres marcoscaceres commented Jan 17, 2018 •

Copy link
Copy Markdown
Member

Closes #645.

Changes show() to take an optional promise that resolves with a PaymentDetailsUpdate:

Promise<PaymentResponse> show(optional Promise<PaymentDetailsUpdate> detailsPromise);

We can then reuse the machinery to perform an update, but splitting it out into its own algorithm


Preview | Diff

Comment thread index.html Outdated
with <var>exception</var>.
</li>
<li>Abort the algorithm.
<li>Return from the method and, <a>in parallel</a>, run the

@marcoscaceres marcoscaceres Jan 17, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The stuff deleted here is just moved and given its own definition below ("update a PaymentRequest's details algorithm").

@marcoscaceres marcoscaceres changed the title wip: allow show to take optional promise wip: allow show() to take optional promise Jan 18, 2018
@marcoscaceres
marcoscaceres requested a review from domenic January 18, 2018 06:10

@domenic domenic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few issues but overall seems to work!

Comment thread index.html
<a>DOMException</a>, and set the <a>user agent</a>'s <a>payment
request is showing</a> boolean to false.
</li>
<li>Otherwise, present a user interface that will allow the user to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The intro text which says "The show() method must act as follows" should be updated to say "the show(detailsPromise) method". Cf. updateWith()'s definition elsewhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated to match method signature.

Comment thread index.html Outdated
<li>Set <var>request</var>.<a>[[\updating]]</a> to true.
</li>
<li>
<a>In parallel</a>, disable the user interface user interface

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should not be done in parallel, as you can't update the UI from off the main thread (i.e. in parallel with the main thread). I guess it's my bad for implying the updating should be done in parallel; it shouldn't. (See later comment.)

Comment thread index.html Outdated
Otherwise, present a user interface to allow the user to interact
with the <var>handlers</var>. The user agent SHOULD prioritize
the preference of the user when presenting payment methods.
Present <var>handlers</var> to the user. The user agent SHOULD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused. Above you displayed a user interface that allowed the user to interact with handlers. Now you are presenting handlers to the user. What is the difference between these two? Why do both?

I think what I would do is add a step in the "If detailsPromise was passed, then:" saying "Re-enable the user interface that allows the users to interact with handlers." And, I would move all the paragraphs in this last step up to the first "present a user interface" step. Am I on the right track?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are correct, I screwed this up.

Comment thread index.html Outdated
with <var>exception</var>.
</li>
<li>Abort the algorithm.
<li>Return from the method and, <a>in parallel</a>, run the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This shouldn't be done in parallel, it turns out; the algorithm just waits on promises, which should be done on the main thread (like it is done in JS).

@marcoscaceres

Copy link
Copy Markdown
Member Author

@domenic, hopefully I understood correctly and you wanted me to drop the "in parallels", right? You are correct that the state machine should handle the signaling to the UI thread while allowing all this to run on the main thread (and just waiting for the detailsPromise to settle).

Giving it another read... to see if it makes sense.

@marcoscaceres

Copy link
Copy Markdown
Member Author

Going to split this into two PR. One editorial one, for the update algo, and then the next for the API change.

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.

Add way to update total and displayItems after .show() but before user interaction

2 participants