mobxjs / mobx.dart

MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.
https://mobx.netlify.app
MIT License
2.39k stars 311 forks source link

feat: add `MultiReactionBuilder` widget #917

Closed amondnet closed 12 months ago

amondnet commented 1 year ago

Merges multiple ReactionBuilder widgets into one widget tree.

MultiReactionBuilder improves the readability and eliminates the need to nest multiple ReactionBuilders.

By using MultiReactionBuilder we can go from:

 ReactionBuilder(
   builder: (context) {},
   child: ReactionBuilder(
     builder: (context) {},
     child: ReactionBuilder(
       builder: (context) {},
       child: ChildA(),
     ),
   ),
 )

to:

 MultiReactionBuilder(
   builders: [
     ReactionBuilder(
       builder: (context) {},
     ),
     ReactionBuilder(
       builder: (context) {},
     ),
     ReactionBuilder(
       builder: (context) {},
     ),
   ],
   child: ChildA(),
 )

MultiReactionBuilder converts the ReactionBuilder list into a tree of nested ReactionBuilder widgets. As a result, the only advantage of using MultiReactionBuilder is improved readability due to the reduction in nesting and boilerplate.


Pull Request Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #917 (5ba18f2) into master (9a97f09) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #917   +/-   ##
=======================================
  Coverage   98.99%   98.99%           
=======================================
  Files          56       57    +1     
  Lines        1987     1990    +3     
=======================================
+ Hits         1967     1970    +3     
  Misses         20       20           
Flag Coverage Δ
flutter_mobx 100.00% <100.00%> (ø)
mobx 98.55% <ø> (ø)
mobx_codegen 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
flutter_mobx/lib/src/multi_reaction_builder.dart 100.00% <100.00%> (ø)
flutter_mobx/lib/src/reaction_builder.dart 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9a97f09...5ba18f2. Read the comment docs.