Skip to content

Instantly share code, notes, and snippets.

@boeledi
Last active March 27, 2023 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boeledi/c4c7f0948af95cc79e8e823efd49d568 to your computer and use it in GitHub Desktop.
Save boeledi/c4c7f0948af95cc79e8e823efd49d568 to your computer and use it in GitHub Desktop.
import 'package:rxdart/rxdart.dart';
class GlobalBloc {
///
/// Streams related to this BLoC
///
final BehaviorSubject<String> _controller = BehaviorSubject<String>();
Function(String) get push => _controller.sink.add;
Stream<String> get stream => _controller;
///
/// Singleton factory
///
static final GlobalBloc _bloc = GlobalBloc._internal();
factory GlobalBloc(){
return _bloc;
}
GlobalBloc._internal();
///
/// Resource disposal
///
void dispose(){
_controller.close();
}
GlobalBloc globalBloc = GlobalBloc();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment