Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/taixw2/eventemitter

Dependency free publish/subscribe(pub/sub) for dart&flutter.
https://github.com/taixw2/eventemitter

Last synced: 5 days ago
JSON representation

Dependency free publish/subscribe(pub/sub) for dart&flutter.

Awesome Lists containing this project

README

        

# eventemitter

Dependency free publish/subscribe(pub/sub) for dart&flutter.

## How to use

Open the `pubspec.yaml` file, and add `eventemitter:` unde dependencies:
``` yaml
dependencies:
flutter:
sdk: flutter
# ...
# ...
eventemitter: ^0.1.3
```
install it from terminal: `Run flutter packages get`

## Example
- [example](./example/main.dart)
- [test](./test/eventemitter_test.dart)

``` dart
String token = EventEmitter.subscribe('topic', (data) {
// receive 2
print(data);
});

// publish is async function
EventEmitter.publish('topic', 1)
EventEmitter.publishSync('topic', 2)
EventEmitter.unsubscribe(token);

```

## Link
- [https://github.com/mroderick/PubSubJS](https://github.com/mroderick/PubSubJS)
- [https://gist.github.com/juliangruber/3160726](https://gist.github.com/juliangruber/3160726)
- [https://github.com/primus/eventemitter3](https://github.com/primus/eventemitter3)