hwc-realtime-streaming

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Real-Time & Streaming

实时与流处理

Implement push-driven Hotwire behavior with Turbo Streams and Stimulus.
通过Turbo Streams和Stimulus实现基于推送的Hotwire行为。

Core Workflow

核心工作流程

  1. Identify transport and delivery shape: WebSocket, SSE, inline stream tags, or server response streams.
  2. Choose default Turbo Stream actions first; add custom actions only when defaults are insufficient.
  3. Keep stream actions small and deterministic; avoid embedding arbitrary scripts in stream payloads.
  4. Separate stream orchestration from domain UI concerns (forms, media, navigation).
  5. Verify ordering, idempotency, and multi-tab behavior for all real-time updates.
  1. 确定传输与交付方式:WebSocket、SSE、内联流标签或服务器响应流。
  2. 优先选择默认的Turbo Stream操作;仅当默认操作无法满足需求时,再添加自定义操作。
  3. 保持流操作简洁且可预测;避免在流负载中嵌入任意脚本。
  4. 将流编排与领域UI关注点(表单、媒体、导航)分离。
  5. 验证所有实时更新的顺序、幂等性以及多标签页行为。

Guardrails

注意事项

  • Prefer
    append/prepend/replace/update/remove/before/after/refresh
    before custom actions.
  • Keep cross-tab sync explicit (BroadcastChannel/localStorage) and scope it to same-device semantics.
  • Use view transitions only where animation meaningfully improves state-change clarity.
  • Validate failure modes for delayed/out-of-order messages.
  • 在使用自定义操作之前,优先使用
    append/prepend/replace/update/remove/before/after/refresh
    这些默认操作。
  • 保持跨标签页同步的明确性(通过BroadcastChannel/localStorage实现),并将其范围限定为同一设备场景。
  • 仅在动画能够切实提升状态变更清晰度的场景下使用视图过渡(View Transitions)。
  • 验证延迟/乱序消息的故障处理模式。

Load References Selectively

选择性加载参考文档

Open only the file needed for the current request.
  • Inline client-side stream tags:
    references/2023-08-01-turbo-streams-inline-stream-tags.md
  • Custom Turbo Stream actions:
    references/2023-08-15-turbo-streams-custom-stream-actions.md
  • Advanced playlist orchestration via custom actions:
    references/2023-10-10-turbo-streams-custom-stream-actions-video-playlist-management.md
  • LocalStorage-backed stream state:
    references/2024-01-30-turbo-streams-custom-stream-actions-localstorage.md
  • List animations with View Transitions:
    references/2025-06-10-turbo-streams-list-animation-view-transitions.md
  • Real-time combobox updates:
    references/2024-03-12-hotwire-combobox-with-real-time-data.md
  • Inter-tab communication patterns:
    references/2023-11-21-stimulus-inter-tab-communication.md
Use
references/INDEX.md
for the full catalog.
仅打开当前需求所需的文档。
  • 客户端内联流标签:
    references/2023-08-01-turbo-streams-inline-stream-tags.md
  • 自定义Turbo Stream操作:
    references/2023-08-15-turbo-streams-custom-stream-actions.md
  • 通过自定义操作实现高级播放列表编排:
    references/2023-10-10-turbo-streams-custom-stream-actions-video-playlist-management.md
  • 基于LocalStorage的流状态管理:
    references/2024-01-30-turbo-streams-custom-stream-actions-localstorage.md
  • 结合View Transitions的列表动画:
    references/2025-06-10-turbo-streams-list-animation-view-transitions.md
  • 实时下拉列表更新:
    references/2024-03-12-hotwire-combobox-with-real-time-data.md
  • 跨标签页通信模式:
    references/2023-11-21-stimulus-inter-tab-communication.md
完整目录请查看
references/INDEX.md

Escalate to Neighbor Skills

关联技能推荐

  • Pull-based navigation/history concerns: use
    hwc-navigation-content
  • Form validation and submit lifecycle concerns: use
    hwc-forms-validation
  • Media playback/upload interactions: use
    hwc-media-content
  • Generic loading/progress/transition UX: use
    hwc-ux-feedback
  • Base Stimulus API questions outside streaming: use
    hwc-stimulus-fundamentals
  • 基于拉取的导航/历史记录相关需求:使用
    hwc-navigation-content
  • 表单验证与提交生命周期相关需求:使用
    hwc-forms-validation
  • 媒体播放/上传交互相关需求:使用
    hwc-media-content
  • 通用加载/进度/过渡体验相关需求:使用
    hwc-ux-feedback
  • 流处理之外的基础Stimulus API问题:使用
    hwc-stimulus-fundamentals