Skip to content

appdev/FlutterRxBus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlutterRxBus

A Flutter EventBus using RxDart

Pub Package Pub Package

GitHub | Pub |

Usage

1. Add to pubspec.yaml

  rxbus: latest version

2. Define Event

Any Dart class or List or any Data can be used as an event.

class ChangeTitleEvent {
  String title;

  ChangeTitleEvent(this.title);
}

3. Register RxBus

Register RxBus

import 'package:rxbus/rx_bus.dart';

RxBus.singleton.register<ChangeTitleEvent>().listen((event) {
      ···//do something
    print(event.title);
    });

4. Send Event

Register listeners for specific events:

 RxBus.singleton.post(ChangeTitleEvent("Changed by event"));

5. Dispose RxBus

  @override
  void dispose() {
    RxBus.destroy();
    super.dispose();
  }

License

The MIT License (MIT)