I have three streams like this:
final _light1RoomCtlr = BehaviorSubject<String>();
final _light2RoomCtlr = BehaviorSubject<String>();
final _light3RoomCtlr = BehaviorSubject<String>();
Stream<String> get getLight1Room => _light1RoomCtlr.stream;
Function(String) get setLight1Room => _light1RoomCtlr.sink.add;
Stream<String> get getLight2Room => _light2RoomCtlr.stream;
Function(String) get setLight2Room => _light2RoomCtlr.sink.add;
Stream<String> get getLight3Room => _light3RoomCtlr.stream;
Function(String) get setLight3Room => _light3RoomCtlr.sink.add;
I want to merge them all so i can get all the values emitted when i need it.
The thing is.. i am using bloc pattern and i don't have a initState() function on it, so i can't initialize stuff.. so dart won't let me do something like this on the same file:
final List<String> _lightRooms = List<String>();
Observable.merge([getLight1Room, getLight2Room, getLight3Room]).listen((room) =>
_lightRooms.add(room);
));
I have tried a lot of things and i keep getting the error message: only static members are initializable.. or something like that.. How can i procede this using reactive programming and bloc pattern? If i do the listening on a widget that i need it, i can lose the info on another one. i tried rxjs examples but here it does not work since this is only class definition things.