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

套件詳情v1.0.1

eventify

一個可取消的事件發射器,支援基於上下文的事件驅動程式設計。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
12.3萬
喜歡數
47
Pub 分數
150

安裝套件

flutter pub add eventify

套件介紹

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

Eventify 是一個可取消的事件發射器,專為 Dart 中的上下文感知、事件驅動程式設計而設計。它透過內建的取消支援,允許事件的發出與監聽,實現元件間的高效通訊,確保不會產生記憶體洩漏。非常適合用於管理應用不同部分的狀態變更、使用者互動或非同步工作流程。該套件支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,使其在跨平台開發中極具彈性。

適用情境

  • 即時通知
  • 複雜UI的狀態管理
  • 將業務邏輯與UI分離
  • 跨螢幕處理使用者互動
  • 管理小部件中的生命週期事件
  • 在服務之間廣播訊息

主要特色

  • 可取消的事件監聽器
  • 上下文感知事件處理
  • 跨平台相容性
  • 輕量且快速
  • 支援非同步事件處理
  • 訂閱與發佈使用的簡潔 API

適合對象

  • 開發響應式應用程式的開發者
  • 使用事件驅動架構的團隊
  • 需要乾淨組件解耦的項目
  • 具有複雜狀態流的應用程式
  • Flutter 應用需要可靠的事件廣播
  • 開發者避免回調地獄

使用建議

  • 需要仔細管理訂閱以避免意外行為
  • 在沒有節流的情況下,不適合高頻率事件串流
  • 在非常簡單的使用案例中可能會引入開銷
  • 最適合中大型應用
  • 需要理解事件生命週期和取消模式

原始 README

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

EventEmitter

EventEmitter for dart. This can be used in any application to register for events and get notified once it is fired.


This library provide mechanism to register for event notifications with emitter or publisher and get notified in the event of an event.

One main advantage of the mehanism is that, it support context from where the subscriber is listening. The context could be any additional data the subscriber is interested in.

Another feature this has is the ability to receive sender information, which could be handy if the subscriber wish to know about the publisher.

Example

    void performAddition(){

    }

    EventCallback cb = (ev, cont) {
        if (null != ev) {
          switch (ev.eventName) {
            case "add":
              performAddition();
              break;
          }
        }
      };

    EventEmitter emitter = new EventEmitter();
    Listener listener = emitter.on("add", this , cb);

    emitter.emit("add","keyboard",10);


As shown in the above example, it is easy to register for events and get notified once it is triggered.

所屬分類

原始碼儲存庫

使用此套件的專案