Skip to content

feat(view): stream deferred views - #295

Draft
petehunt wants to merge 2 commits into
tokio-rs:mainfrom
petehunt:agent/deferred-views
Draft

feat(view): stream deferred views#295
petehunt wants to merge 2 commits into
tokio-rs:mainfrom
petehunt:agent/deferred-views

Conversation

@petehunt

@petehunt petehunt commented Aug 3, 2026

Copy link
Copy Markdown

Depends on #292 and reworks the #290 streaming-shell concept around the ordinary View type. Review the commit after a02c230 for the deferred-view diff.

Summary

  • Add defer component() { placeholder } syntax and View::defer for manual futures.
  • Store deferred work as a view part, so components, layouts, and nested deferred views compose normally without ShellView, include(), or finish().
  • Stream the shell first and completed fragments in completion order; dropping the response body cancels pending work.
  • Send inert annotated <template> patches and apply them as they arrive with the parser-blocking external defer_script() asset, with no inline scripts.
  • Add focused coverage, formatter/docs updates, and a runnable deferred-view example.

This is more integrated than #290: it adds a deferred view-part variant, lets the router retain an owned request context while streaming, and makes futures-util a normal router dependency. In exchange, every view can participate and composition needs no parallel type or helper. Deferred tasks are one-shot; cloned views share the same task.

Testing

  • cargo +nightly fmt --all
  • cargo topcoat fmt (expected Leptos parse errors only)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test --workspace --all-features
  • RUSTDOCFLAGS="--cfg docsrs -Dwarnings" cargo +nightly doc --workspace --all-features --no-deps --locked
  • cargo check -p deferred-view
  • node --check crates/topcoat/browser/defer.js

Created by OpenAI Codex (GPT-5), which implemented and locally verified the change under maintainer direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant