-
-
Save boeledi/c4c7f0948af95cc79e8e823efd49d568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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