turbo_stream: Turbo Stream

Description Usage Arguments Details See Also

View source: R/turbo-stream.R

Description

Turbo Streams deliver page changes as fragments of HTML wrapped in self-executing <turbo-stream> elements. Each stream element specifies an action together with a target ID to declare what should happen to the HTML inside it. These elements are delivered by the server over a WebSocket, SSE or other transport to bring the application alive with updates made by other users or processes.

Usage

1
2
3
4
5
6
7
turbo_stream(
  action = c("append", "prepend", "replace", "update", "remove", "before", "after"),
  target,
  ...,
  multiple = FALSE,
  env = parent.frame()
)

Arguments

action

(str) the action to be taken for this stream element:

  • append - inserted last inside the element

  • prepend - inserted first inside the element

  • replace - replace the whole element

  • update - replace the element but keep handlers intact; only HTML

  • remove - remove the element

  • before - insert before the element

  • after - insert after the element

target

(str) target of any links clicked in this:

  • NULL - the frame itself

  • "_top" - the whole window

  • "<id>" - a specific frame outside tof the current frame

...

(tag) content of the element

multiple

(flg) if multiple targets, where target is CSS selector

env

(env) calling environment

Details

It’s good practice to start your interaction design without Turbo Streams. Make the entire application work as it would if Turbo Streams were not available, then layer them on as a level-up. This means you won’t come to rely on the updates for flows that need to work in native applications or elsewhere without them.

See Also

Other Turbo: turbo_assets(), turbo_frame(), turbo_link(), turbo_listener(), turbo_modifiers, turbo


tjpalanca/hotwire.R documentation built on Dec. 23, 2021, 10:59 a.m.