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 wrap with observer assist #949

Closed amondnet closed 8 months ago

amondnet commented 10 months ago

Describe the changes proposed in this Pull Request.

If the PR fixes a specific issue, reference the issue with Fixes #.

wrap_with_observer


Pull Request Checklist

codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (827bb5d) 99.00% compared to head (27a6bd1) 99.00%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949/graphs/tree.svg?width=650&height=150&src=pr&token=YjGMFvwbrl&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs)](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) ```diff @@ Coverage Diff @@ ## main #949 +/- ## ======================================= Coverage 99.00% 99.00% ======================================= Files 57 57 Lines 2006 2006 ======================================= Hits 1986 1986 Misses 20 20 ``` | [Flag](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | Coverage Δ | | |---|---|---| | [flutter_mobx](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | `100.00% <ø> (ø)` | | | [mobx](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | `98.56% <ø> (ø)` | | | [mobx_codegen](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | `100.00% <ø> (ø)` | | | [mobx_lint](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) | `∅ <ø> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs#carryforward-flags-in-the-pull-request-comment) to find out more. ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs). Last update [827bb5d...27a6bd1](https://app.codecov.io/gh/mobxjs/mobx.dart/pull/949?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mobxjs).
pavanpodila commented 10 months ago

Looks like a cool addition. We could do a lot more with this I think. A few ideas:

  1. Flag Observers that don't have an observable in the builder?
  2. Add reaction in the initState of a StatefulWidget with proper dispose
  3. Generate stubs for wrapping an observable mutation to happen inside a runInAction()
subzero911 commented 10 months ago
image

Already exists in flutter_mobx VsCode extension. But! it fails on some very large pieces of code: https://github.com/Flutterando/flutter_mobx_extension/issues/17

netlify[bot] commented 9 months ago

Deploy request for mobx pending review.

Visit the deploys page to approve it

Name Link
Latest commit 27a6bd1fd4d15bb3b7ea760401a86aea68a4f45c
pavanpodila commented 8 months ago

Hi @amondnet, can we move this package under the mobx publisher ?