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

套件詳情v1.0.2

livestream

LiveStream 是一個簡單的類別,可讓您應用程式的不同模組之間輕鬆通訊。

近 30 天下載
29
喜歡數
29
Pub 分數
40

安裝套件

flutter pub add livestream

套件介紹

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

Livestream 是一個輕量級的 Flutter 套件,旨在簡化應用程式不同部分之間的通訊。它提供了一種簡單的方式來廣播和監聽事件,非常適合用於狀態管理與模組間通訊,而不需複雜的大框架。該套件以簡單的發佈-訂閱模式為基礎,可讓小組件、服務或畫面之間實現高效的資料流。僅需最少設定且無外部相依性,Livestream 能提升 Flutter 應用的模組化與回應能力。

適用情境

  • 即時事件廣播
  • 跨小部件通訊
  • 簡化狀態更新
  • 解耦應用模塊
  • 跨螢幕處理使用者動作
  • 簡化外掛程式互動

主要特色

  • 簡單的發佈-訂閱模型
  • 最小化樣板程式碼
  • 無外部依賴
  • 輕量且快速
  • 與現有程式碼的輕鬆整合
  • 支援類型化事件

適合對象

  • 中小型Flutter應用
  • 尋求輕量級狀態管理的開發者
  • 避免複雜依賴注入的團隊
  • 需要快速事件驅動通訊的應用程式
  • 快速原型用戶介面更新
  • 優先考慮簡單性而非可擴展性的項目

使用建議

  • 不適合大規模狀態管理
  • 僅限基本事件處理
  • 無內建的持久化或還原功能
  • 最適合暫時或瞬時資料
  • 在長時間運行的應用程式中可能需要手動清理
  • 不適合複雜的資料同步

原始 README

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

LiveStream - Dart

Pub Github Followers GitHub stars GitHub forks GitHub watchers Twitter Follow

LiveStream is a data holder class which can observe change of data in real-time and emit values too. Here's emitter subscriber pattern. It's developed in pure Dart.

⚡️ Getting Started

Add Dependency

Add below dependency in pubspec.yaml.

dependencies:
  livestream: ^1.0.2
Initialize LiveStream Instance

You can create instance as below.

  LiveStream liveStream = new LiveStream();
Subscribe to Stream / Add Observer

LiveStream event will be dispatched when data is changed. See below code to add observer / subscriber.

    liveStream.on("chat-message", (message) {
      print("Message Received: $message");
    });

Whenever data is emitted to chat-message channel/stream above block will be executed.

Emitting Events or Broadcasting

The main idea behind LiveStream is that you can send and receive any events you want, with any data you want. Any objects that can be encoded as JSON will do, and binary data is supported too. See code below.

  void send() {
      String message = "Hi there!";
      liveStream.emit("chat-message", message);
  }

🚀 Sample Usage

Sample code is available in /example directory.

🤝 Contribute

If you want to contribute to this library, you're always welcome! See Contributing Guidelines.

✉️ Contact

If you need any help, you can connect with me.

Visit:- shreyaspatil.dev

📃 License

MIT License

Copyright (c) 2020 Shreyas Patil

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。