mobx_codegen 0.3.5

mobx_codegen #

pub package CircleCI

MobX Code Generation library

Adds support for annotating your MobX code with @observable, @computed, @action, making it super simple to use MobX.

Note that these annotations only work inside store-classes.

store-classes are abstract and use the Store mixin. When you run the build_runner, it will automatically generate the *.g.dart file that must be imported in your file.

$> cd $YOUR_PROJECT_DIR
$> flutter packages pub run build_runner build

Example #

import 'package:mobx/mobx.dart';

// Include generated file
part 'todos.g.dart';

// This is the class used by rest of your codebase
class Todo = TodoBase with _$Todo;

// The store-class
abstract class TodoBase with Store {
  TodoBase(this.description);

  @observable
  String description = '';

  @observable
  bool done = false;
}

0.3.5 #

  • Added the ability to create Store classes using the @store annotation. It can be added to a private class, which will result in a public generated class.

0.3.4 #

  • Refactored some tests that rely on source-text to not be based on hard-coded strings. These have been moved to a separate file for easier maintenance. The outputs resulting from the generator are also in a separate file. This allows scaling to more variations of source-text in the future.
  • Added checks to ensure @observable and @computed are used for the correct members of the class. These are reported as errors during the codegen process.
  • Upgraded test_coverage
  • Fixed a bunch of analyzer errors

0.3.1 - 0.3.3+1 #

  • Adding a conditional action-wrapper for field setters.
  • Increasing test coverage
  • Adapting to the API change in mobx 0.3.3
  • Formatting changes

0.3.0 - 0.3.0+1 #

  • Adapting to the API changes in mobx 0.3.0
  • README.md updates

0.2.1+2 #

  • Removing the code in /example folder and instead having a simple README.md in it.

0.2.1+1 #

  • README updates

0.2.1 #

  • Upgrading to use the 0.2.1 version of mobx, which makes it compatible with the latest beta/dev/master channels

0.2.0 #

  • A breaking change has been introduced to the use of the Store type. Previously it was meant to be used as an interface, which has now changed to a mixin.

0.0.2 - 0.1.3 #

  • Move all the codegen parts to separate templates
  • Documentation updates
  • Support for async actions
  • CircleCI integration improvements

0.0.1 - First Release #

  • Added support for @observable, @computed and @action

example/README.md

Using mobx_codegen #

Refer to this Getting Started guide for using mobx_codegen with mobx.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mobx_codegen: ^0.3.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mobx_codegen/mobx_codegen.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
90
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
88
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

We analyzed this package on Aug 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: other

Primary library: package:mobx_codegen/mobx_codegen.dart with components: io, build, mirrors.

Health suggestions

Format lib/src/template/store.dart.

Run dartfmt to format lib/src/template/store.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (analyzer).

The description is too long. (-2 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
analyzer ^0.36.3 0.36.4 0.38.1
build ^1.1.4 1.1.6
mobx ^0.3.6 0.3.6
path ^1.6.2 1.6.4
source_gen ^0.9.4 0.9.4+4
Transitive dependencies
args 1.5.2
async 2.3.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.2
csslib 0.16.1
dart_style 1.2.9 1.2.10
front_end 0.1.19 0.1.23
glob 1.1.7
html 0.14.0+2
kernel 0.3.19 0.3.23
meta 1.1.7
package_config 1.1.0
pedantic 1.8.0+1
pub_semver 1.4.2
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.1.16
Dev dependencies
build_runner ^1.4.0
build_test ^0.10.8
logging ^0.11.3 0.11.3+2
mockito ^4.0.0
test ^1.6.3
test_coverage ^0.3.0