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.
This still needs some additional more tests and docs prior to merging but I wanted to open this for comment on the general approach.
This is a proposed solution for #906
This PR introduces the concept of versioning for Turbo stream
update
andreplace
actions, see the above issue for more background.Functionality:
data-steam-version
on stream target element.version
on theturbo-stream
element.update
andreplace
: If versions are present, they are parsed as numeric values and compared, actions are rejected unless the new version is greater than the existing version.The current API presented here does not attempt to automatically manage the versions within template content, i.e. an update looks like this:
Versioning information ends up duplicated both in the
turbo-stream
and the template content.In theory we could search the template content for the target selector and propagate the version down from the
turbo-stream
element. But I think this is "too smart" and likely to have edge cases. I suspect most usage ofturbo
is via higher level libraries, liketurbo-rails
, and I think those layers should be able to mask the duplication given more domain knowledge.Let me know what ya think and I'll wrap this up.