-
-
Notifications
You must be signed in to change notification settings - Fork 364
[WIP] [Live] Make Ajax calls happen in serial, with "queued" changes #466
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kbond
reviewed
Sep 19, 2022
This was referenced Sep 20, 2022
49273ce
to
4fbcebe
Compare
weaverryan
added a commit
that referenced
this pull request
Sep 27, 2022
… sync bug & auto-setting data-model values (weaverryan) This PR was merged into the 2.x branch. Discussion ---------- [Waiting][Live] Doc'ing how to set values via Js, select sync bug & auto-setting data-model values | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | Fixes #469 Fixes #473 | License | MIT This does 3 unrelated things to close #469 and #473 **NOTE: BUILT ON TOP OF #466 A) [X] Documents how to change a "model" field via JavaScript B) [X] Fixes a problem where a `select` element is rendered without an `empty` option, and so the component data isn't aware of the pre-selected option. C) [X] Automatically set the `value` of a `data-model` field - #473. Cheers! Commits ------- af084ba doc'ing how to set values via JS, auto-set "value" of model elements, sync empty select fields
weaverryan
added a commit
that referenced
this pull request
Sep 27, 2022
…verryan) This PR was merged into the 2.x branch. Discussion ---------- [Live] Action and Model-based data-loading behavior | Q | A | ------------- | --- | Bug fix? | yes/no | New feature? | yes | Tickets | Fix #462 and Feature E | License | MIT NOTE: BUILT ON TOP OF #466. Been wanting this for awhile :): only trigger loading behavior on an element for a specific action. ``` <span data-loading="action(saveForm)|show">Loading</span> ``` Or only when a specific model has been updated: ``` <span data-loading="model(email)|show">Loading</span> ``` TODO: * [x] Let's also add "model" loading to this PR as well Commits ------- 4e846d8 data-load only for specific actions or model updates
fullstackdeveloperwebapp
added a commit
to fullstackdeveloperwebapp/ux
that referenced
this pull request
Aug 1, 2023
… sync bug & auto-setting data-model values (weaverryan) This PR was merged into the 2.x branch. Discussion ---------- [Waiting][Live] Doc'ing how to set values via Js, select sync bug & auto-setting data-model values | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | Fixes #469 Fixes #473 | License | MIT This does 3 unrelated things to close #469 and #473 **NOTE: BUILT ON TOP OF symfony/ux#466 A) [X] Documents how to change a "model" field via JavaScript B) [X] Fixes a problem where a `select` element is rendered without an `empty` option, and so the component data isn't aware of the pre-selected option. C) [X] Automatically set the `value` of a `data-model` field - #473. Cheers! Commits ------- af084ba doc'ing how to set values via JS, auto-set "value" of model elements, sync empty select fields
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
Consider the following situation:
A) Model update is made: Ajax call starts
B) An action is triggered BEFORE the Ajax call from (A) finishes.
Previously, we would start a 2nd Ajax call for (B) before the Ajax call from (A) finished... meaning two Ajax calls were happening at the same time. There are a few problems with this: (i) Ajax call (B) is missing any potential data changes from Ajax call (A) and (i) complexity of multiple things loading at once, and potentially finishing in a different order.
This PR simplifies things, which matches Livewire's behavior anyways. Now, the action from (B) will WAIT until the Ajax call from (A) finishes and THEN start. In fact, while an Ajax call is being made, all changes (potentially multiple model updates or actions) will be "queued" and then all set at once on the next request.
TODO:
data
key in JSON. Previously the entire body was the "data".args
key in the JSON.batch
action Ajax calls/batch
action needs to be added that can handle multiple actions at onceupdatedModels
is sent on the ajax requests. If the signature fails, use this to give a better error message about what readonly properties were just modified. (in fact, this is the only purpose of sending this new field to the backend at this time).Pass aFor consistency, we will always pass theincludeUpdatedModels
value to the Stimulus controller ONLY when indev
mode.updatedModels
in our Ajax requests, though this is intended to be "internal" and we won't use it other than to throw better errors.(Optional) If the backend has an unexpected exception (i.e. 5xx or maybe some 4xx where we mark that this is a problem we should show the developer), then render the entire HTML exception page (in dev mode only) so the user can see the error.Done in [Live] Rendering any errors in a simple modal #467Cheers!