Skip to content

Instantly share code, notes, and snippets.

@Ankit-Slnk
Created June 19, 2021 10:53
Show Gist options
  • Save Ankit-Slnk/0cf0e7451375d1eb9b3afe7356d77e29 to your computer and use it in GitHub Desktop.
Save Ankit-Slnk/0cf0e7451375d1eb9b3afe7356d77e29 to your computer and use it in GitHub Desktop.
singleton bloc stream using rxdart
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