LiveStream - Dart #

LiveStream is a data holder class which can observe change of data in real-time and emit values too. Here's emitter subscriber pattern. It's developed in pure Dart.

⚡️ Getting Started #

Add Dependency #

Add below dependency in pubspec.yaml .

dependencies: livestream: ^1.0.2

Initialize LiveStream Instance #

You can create instance as below.

LiveStream liveStream = new LiveStream();

LiveStream event will be dispatched when data is changed. See below code to add observer / subscriber.

liveStream.on("chat-message", (message) { print("Message Received: $message"); });

Whenever data is emitted to chat-message channel/stream above block will be executed.

Emitting Events or Broadcasting #

The main idea behind LiveStream is that you can send and receive any events you want, with any data you want. Any objects that can be encoded as JSON will do, and binary data is supported too. See code below.

void send() { String message = "Hi there!"; liveStream.emit("chat-message", message); }

🚀 Sample Usage #

Sample code is available in /example directory.

If you want to contribute to this library, you're always welcome! See Contributing Guidelines.

If you need any help, you can connect with me.

Visit:- shreyaspatil.dev