Dart package to which makes data communication easy among different modules of your application.

Overview

LiveStream - Dart

Pub Github Followers GitHub stars GitHub forks GitHub watchers Twitter Follow

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();

Subscribe to Stream / Add Observer

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.

🤝 Contribute

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

✉️ Contact

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

Visit:- shreyaspatil.dev

📃 License

MIT License

Copyright (c) 2020 Shreyas Patil

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You might also like...

A Flutter plugin that allows communication with a Parse Server

A Flutter plugin that allows communication with a Parse Server

Parse For Flutter! Hi, this is a Flutter plugin that allows communication with a Parse Server, (https://parseplatform.org) either hosted on your own s

Apr 14, 2022

This a library to simplify isolate thread communication.

This a library to simplify islate thread communication. It abstracts the data transfer between islate and the main thread into a simple channel, and t

Oct 31, 2022

An example of "reactive/streaming repository" as a solution for BLoC to BLoC communication

An example of

Reactive Repositories An example of listening to a Stream from repository layer (instead of explicitly using get/fetch) as a solution for BLoC to BLoC

Jan 3, 2023

Data Migrator - provide a universal translator for data by being portable, diverse, and efficient in migrating and converting data across discrete schemas

Data Migrator - provide a universal translator for data by being portable, diverse, and efficient in migrating and converting data across discrete schemas

Data Migrator - provide a universal translator for data by being portable, diverse, and efficient in migrating and converting data across discrete schemas

Jan 2, 2023

Encode App-Dev is a open source project which contains different projects of Application development, Android development, IOS development, Flutter, Kotlin, Dart, Java, Swift etc.

HACKTOBERFEST 2022 Encode App-Dev is an open source project which contains different projects of Application development, Android development, IOS dev

Dec 4, 2022

A CustomPaint example where we can draw with different colors and different stroke sizes

A CustomPaint example where we can draw with different colors and different stroke sizes

CustomPaint A CustomPaint example where we can draw with different colors and different stroke sizes. A Flutter application which runs on iOS, Android

Dec 27, 2021

Dart package for Async Data Loading and Caching. Combine local (DB, cache) and network data simply and safely.

Dart package for Async Data Loading and Caching. Combine local (DB, cache) and network data simply and safely.

Stock is a dart package for loading data from both remote and local sources. It is inspired by the Store Kotlin library.

Dec 24, 2022

Response Parser makes it easier to parse data and error response from server.

Response Parser makes it easier to parse data and error response from server. Getting started Do you want to write this pretty functions... FutureEit

Nov 5, 2022

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing

Jan 8, 2023
Comments
  • how to update UI in callback?

    how to update UI in callback?

    I using a callback, when livestream gives me an emit message, can I need call setState to update UI,

    but there was any error everytime I try to update UI:

    E/flutter (19781): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
    E/flutter (19781): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
    E/flutter (19781): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
    E/flutter (19781): #0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1112:9)
    E/flutter (19781): #1      State.setState (package:flutter/src/widgets/framework.dart:1147:6)
    E/flutter (19781): #2      _ChatPageState._solveReceivedMessage (package:tunnel/tab_page/tab1_children/chat_page3.dart:396:9)
    E/flutter (19781): #3      _ChatPageState.initState.<anonymous closure> (package:tunnel/tab_page/tab1_children/chat_page3.dart:216:7)
    E/flutter (19781): #4      _DataStore.setValue.<anonymous closure> (package:livestream/livestream.dart:54:15)
    

    what should we properly update UI in callback?

    opened by jinfagang 5
Releases(1.0.2)
Owner
Shreyas Patil
💼Android Engineer @ Paytm Insider, 👨‍💻Google Developer Expert for Android, ❤️Kotlin, 👨‍🚀Organizer @KotlinMumbai
Shreyas Patil
Nexus is a state management library that makes it easy to create and consume your application's reactive data to the user interface.

Nexus ?? Nexus is a state management library that makes it easy to create and consume your application's reactive data to the user interface. With nex

Gor Mkhitaryan 3 Sep 7, 2022
Split your bill among friends.

Bill-Split-App Split your bill among friends. Preview ?? split.mp4 Full Video ?? INSTAGRAM ⚙️ Built with Amazing Tools Flutter - Beautiful native apps

Flutter Queen 3 Oct 20, 2022
Rajagiri connect is a networking platform that enables the students of Rajagiri to form a social network among themselves, enabling them to connect with their seniors, juniors and faculty for sharing of information and resources.

Rajagiri Connect Rajagiri connect is a networking platform that enables the students of Rajagiri to form a social network among themselves, enabling t

Muhammad Amaan 2 Nov 27, 2022
Allows communication between your bot and the Web App built in Flutter displayed inside Telegram.

tele_web_app It enables communication between your bot and the Flutter-embedded Web App displayed inside Telegram by making use of interoperability be

Yeikel Uriarte Arteaga 16 Dec 8, 2022
Anonchat-v2 - Anonchat - A microprotocol for communication build on Dart using sockets

AnonChat Originally made by Arslee on arslee07/anonchat. What's this? Anonchat i

null 6 Nov 11, 2022
A library that makes it easy for you to create your own custom wizard.

Flutter Wizard Author: Jop Middelkamp A library that makes it easy for you to create your custom wizard. You'll have 100% control over the appearance

Baseflow 13 Dec 2, 2022
ToDo App made with flutter which stores your todos based on their categories. The data is stored in external application storage in your device in JSON file.

⭐ My ToDo ⭐ Built with ❤︎ by Akash Debnath This is my second project on Flutter. This app hepls you to keep record of your ToDos. You can create your

Akash Debnath 38 Dec 25, 2022
🙌🏾 This package makes it easy to use the Mono connect widget in a flutter project

Flutter Mono ** This is an unofficial SDK for flutter This package makes it easy to use the Mono connect widget in a flutter project. ?? Screen Shots

Chiziaruhoma Ogbonda 12 Dec 20, 2022
Powerful, helpfull, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server with boilerplate code free.

flutter_axelor_sdk Powerful, helpful, extensible and highly customizable API's that wrap http client to make communication easier with Axelor server w

Abd al-Rahman al-Ktefane 5 Dec 25, 2022