get_event_bus 1.0.0 copy "get_event_bus: ^1.0.0" to clipboard
get_event_bus: ^1.0.0 copied to clipboard

A minimal and scalable light-weight event bus library for get.dart

example/example.md

Examples #

Basic #

import 'package:get/get.dart';
import 'package:get_event_bus/get_event_bus.dart';

class MyEvent {}
class MyEvent1 extends MyEvent {}
class MyEvent2 extends MyEvent {}
class MyEvent3 extends MyEvent {}

void main() {
  Get.bus.on<MyEvent>((event) => Get.log('called')); // will be called 3 times
  Get.bus.once<MyEvent>((event) => Get.log('called')); // will be called 1 times
  Get.bus.on<MyEvent1>((event) => Get.log('called')); // will be called 1 times
  Get.bus.on<MyEvent2>((event) => Get.log('called')); // will be called 0 times
  
  Get.bus.fire(MyEvent1());
  Get.bus.fire(MyEvent2());
  Get.bus.fire(MyEvent3());
}

Customize #

import 'package:get/get.dart';
import 'package:rxdart/rxdart.dart';
import 'package:get_event_bus/get_event_bus.dart';

class MyEventBus extends EventBus {
  // your customized code HERE
}

void main() {
	Get.bus.streamController = PublishSubject(); // customize StreamController
  
 	GetEventBusExtension.eventBus = MyEventBus(); // customize entire mounted EventBus
}
3
likes
160
pub points
70%
popularity

Publisher

unverified uploader

A minimal and scalable light-weight event bus library for get.dart

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, get

More

Packages that depend on get_event_bus