패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.7.0

event_bus_plus

Dart용 이벤트 버스입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
5.2천
좋아요
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 개

소스 저장소

이 패키지를 사용하는 프로젝트