パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.7.0

event_bus_plus

Dart用のイベントバス。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
5220
いいね数
40
Pub ポイント
130

パッケージをインストール

flutter pub add event_bus_plus

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

EventBusPlus は、Flutter アプリケーション内のオブジェクト間の簡単かつ効率的な通信を可能にする、Dart 用の軽量なイベントバス実装です。型安全なイベント配信と購読をサポートしており、強い依存関係なしにコンポーネントを分離するのに最適です。使いやすさを重視し、明確な API を備えており、開発者がアプリのさまざまな部分でイベントを発行し、それらをリッスンできるように設計されています。Android、iOS、Web、macOS、Windows、Linux などの主要プラットフォームすべてでスムーズに動作します。

用途

  • UIコンポーネントの分離
  • クロスウィジェット通信の処理
  • アプリ全体の状態変更の管理
  • ナビゲーションイベントの簡素化
  • ブロードキャスト通知
  • プラグインイベントシステムの実装

主な機能

  • 型安全なイベント処理
  • シンプルなサブスクライブおよびエミット API
  • クロスプラットフォーム互換性
  • 軽量でオーバーヘッドが最小限
  • イベントのキャンセルをサポート
  • 洗練された直感的な構文

適している対象

  • 軽量な状態管理を求める開発者
  • 頻繁なコンポーネント間通信を持つアプリ
  • 複雑な状態ソリューションを避けるプロジェクト
  • pub-subパターンを好むチーム
  • 迅速なイベント駆動型機能のプロトタイピング

注意事項

  • 大規模な状態管理には適していない
  • 限定された組み込みエラー処理
  • 永続化または直列化のサポートなし
  • 他の状態管理アプローチと併用するのが最適です
  • メモリリークを回避するため、注意深くクリーンアップが必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

EventBus: Events for Dart/Flutter

pub package codecov Dart

EventBus is an open-source library for Dart and Flutter using the publisher/subscriber pattern for loose coupling. EventBus enables central communication to decoupled classes with just a few lines of code – simplifying the code, removing dependencies, and speeding up app development.

event bus publish subscribe

Your benefits using EventBus: It…

  • simplifies the communication between components;
  • decouples event senders and receivers;
  • performs well with UI artifacts (e.g. Widgets, Controllers);
  • avoids complex and error-prone dependencies and life cycle issues.
event bus plus
Define the app's events
// Initialize the Service Bus
IAppEventBus eventBus = AppEventBus();

// Define your app events
final event = FollowEvent('@devcraft.ninja');
final event = CommentEvent('Awesome package 😎');
Subscribe
// listen the latest event
final sub = eventBus.last$
        .listen((AppEvent event) { /*do something*/ });

// Listen particular event
final sub2 = eventBus.on<FollowAppEvent>()
        .listen((e) { /*do something*/ });
Publish
// fire the event
eventBus.fire(event);
Watch events in progress
// start watch the event till its completion
eventBus.watch(event);

// and check the progress
eventBus.isInProgress<FollowAppEvent>();

// or listen stream to check the processing
eventBus.inProgress$.map((List<AppEvent> events) =>
        events.whereType<FollowAppEvent>().isNotEmpty);

// complete
_eventBus.complete(event);

// or complete with completion event
_eventBus.complete(event, nextEvent: SomeAnotherEvent);

History

final events = eventBus.history;

Mapping

final eventBus = bus = EventBus(
        map: {
          SomeEvent: [
            (e) => SomeAnotherEvent(),
          ],
        },
      );

Contributing

We accept the following contributions:

Maintainers

  • [Andrew Piterov](mailto:contact@andrewpiterov.com?subject=[GitHub]%20Source%20Dart%event_bus_plus)

カテゴリー

依存関係

依存関係一覧 4 件

ソースリポジトリ

このパッケージを使用しているプロジェクト