Model rendering overhaul #378
Merged
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!
tl;dr
This PR makes it so that you only need to use
data-modelto bind an input to aLivePropon your component object. This also introduces:A) model modifiers (e.g.
data-model="on(change)|norender|firstName"to update the model on change and skip re-rendering)B) A new way to "opt in" to the
nameattribute being used in place ofdata-model: you now add adata-modelto theformtag surrounding your fields:<form data-model"*">.All of this is explained more in the CHANGELOG and documentation.
The motivation behind this change was actually to fix a bug. If you typed into field (A), then quickly typed into field (B) before the re-render Ajax request finished from changing field (A), when that Ajax call did finish, it would "replace" your custom changes to field (B). Basically, what you just typed disappears. Fixing this meant making
live_controller.tslisten to theinputevent in all situations and track "unsynced inputs". And since we were now listening to theinputevent all the time, it seemed logical to no longer require the user to do this manually withdata-action="live#update".This PR also overhauls the test suite to make it much more readable and user friends 🌞 and also completes the conversion to TypeScript by removing all of the TS warnings.
Cheers!