Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ややcomplexなBLoCへの対応

 ややcomplexなBLoCへの対応

"Flutter Meetup Tokyo #7"でのLT資料です。
https://flutter-jp.connpass.com/event/115645/

Hiroki Matsue

January 30, 2019
Tweet

More Decks by Hiroki Matsue

Other Decks in Programming

Transcript

  1. ·ͣܖ໿ͱSIM2ͭͷBLoCΛܨ͙ You should avoid having one BLoC as a parameter

    of another BLoC. Instead, plug only the required outputs to the applicable inputs. This helps avoid tight coupling. https://medium.com/flutter-io/build-reactive-mobile-apps-in-flutter-companion- article-13950959e381 _bloc = SimBloc(widget.sim); // ܖ໿BLoCͷstreamΛSIMBLoC͕listen _subscription = widget.simsStream.listen(_bloc.sims.add);
  2. class SimBloc { SimBloc(Sim sim) { _simController.stream .map((list) => list.firstWhere((s)

    => s == sim, orElse: () => null)) .listen((sim) { if (sim == null) { log(errorMessage); // print log and send error to Sentry return; } _simSubject.add(SimState( switchingStatus: SimSwitchingStatus.fulfilled, isEnabled: sim.isEnabled, usage: sim.inMonthUsage(), )); ...