Created
June 19, 2021 10:53
-
-
Save Ankit-Slnk/0cf0e7451375d1eb9b3afe7356d77e29 to your computer and use it in GitHub Desktop.
singleton bloc stream using rxdart
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 SampleBloc { | |
static final SampleBloc _singletonBloc = new SampleBloc._internal(); | |
final sampleBlocObj = BehaviorSubject<int>(); | |
factory SampleBloc() { | |
return _singletonBloc; | |
} | |
SampleBloc._internal() { | |
sampleBlocObj.value = 1; | |
} | |
dispose() { | |
sampleBlocObj.close(); | |
} | |
} | |
final sampleBloc = SampleBloc(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment