Skip to content

Instantly share code, notes, and snippets.

@Vanethos
Created September 26, 2019 05:44
Show Gist options
  • Save Vanethos/51f074c0ffabaf210ee88990296f3405 to your computer and use it in GitHub Desktop.
Save Vanethos/51f074c0ffabaf210ee88990296f3405 to your computer and use it in GitHub Desktop.
import 'package:rxdart/rxdart.dart';
class ABloc {
/// Input from the user
var _inputSubject = PublishSubject<int>();
Sink<int> get inputSink => _inputSubject.sink;
/// Output for the user
var _outputSubject = PublishSubject<int>();
Stream<int> get outputStream => _outputSubject.stream;
ABloc() {
/// Get the input stream, add 1 and return to the view
_inputSubject
.stream
.listen((value) => _outputSubject.add(value + 1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment