搜尋套件、儲存庫與 APP 分類

套件詳情v1.3.0

action_cable

Dart 中的 ActionCable 客戶端,可在 Web、dartVM 和 Flutter 中使用。

AndroidiOSmacOSWindowsLinux
近 30 天下載
1490
喜歡數
22
Pub 分數
135

安裝套件

flutter pub add action_cable

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

ActionCable 是 Rails 的 ActionCable 的 Dart 客戶端實作,可在 Flutter 和 Dart 應用中透過 WebSocket 實現即時雙向通訊。它支援 Web、DartVM 及 Android、iOS、macOS、Windows 與 Linux 等行動平台。此套件可與 ActionCable 伺服器無縫整合,實現即時更新、聊天系統與通知等功能。提供簡潔的 API,可用於訂閱頻道、接收訊息,並透過內建重連機制管理連線。非常適合需要即時資料同步的應用。

適用情境

  • 即時聊天應用
  • 即時儀表板更新
  • 通知系統
  • 協作編輯工具
  • 串流資料餵送

主要特色

  • 基於 WebSocket 的即時通訊
  • 跨平台支援(網頁、行動裝置、桌面)
  • 頻道訂閱管理
  • 自動重連
  • 簡單的事件驅動 API

適合對象

  • 需要即時功能的Flutter應用
  • 使用 Rails 後端的 Dart 項目
  • 開發即時互動式 UI 的開發者
  • 需要低延遲更新的應用
  • 在伺服器端使用 ActionCable 的團隊

使用建議

  • 需要相容的 ActionCable 伺服器
  • 網路可靠性影響效能
  • 與成熟的替代方案相比,文件有限
  • 需要手動處理訊息解析
  • 未經調優,不適用於高頻率、低延遲場景

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Pub

All Contributors

ActionCable in Dart

ActionCable is the default realtime websocket framework and protocol in Rails.

This is a dart port of the client and protocol implementation which is available in web, dartVM and flutter.

Usage

Connecting to a channel 🙌
cable = ActionCable.connect(
  "ws://10.0.2.2:3000/cable",
  headers: {
    "Authorization": "Some Token",
  },
  onConnected: (){
    print("connected");
  },
  onConnectionLost: () {
    print("connection lost");
  },
  onCannotConnect: () {
    print("cannot connect");
});
Subscribing to channel 🎉
cable.subscribe(
  "Chat", // either "Chat" and "ChatChannel" is fine
  channelParams: { "room": "private" },
  onSubscribed: (){}, // `confirm_subscription` received
  onDisconnected: (){}, // `disconnect` received
  onMessage: (Map message) {} // any other message received
);
Unsubscribing from a channel 🎃
cable.unsubscribe(
  "Chat", // either "Chat" and "ChatChannel" is fine
  {"room": "private"}
);
Perform an action on your ActionCable server 🎇

Requires that you have a method defined in your Rails Action Cable channel whose name matches the action property passed in.

cable.performAction(
  "Chat",
  action: "send_message",
  channelParams: { "room": "private" },
  actionParams: { "message": "Hello private peeps! 😜" }
);
Disconnect from the ActionCable server
cable.disconnect();

ActionCable protocol

Anycable has a great doc on that topic.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Clinton

💻 ⚠️

Hamad AlGhanim

💻

Fareesh Vijayarangam

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。