Skip to content

Commit

Permalink
fix: revert mobxjs#784 (mobxjs#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
amondnet authored and tlvenn committed Dec 31, 2022
1 parent 2935183 commit a55063b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
4 changes: 4 additions & 0 deletions mobx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.7+5

- revert #784 - [@amondnet](https://github.com/amondnet)

## 2.0.7+4
fixes:
- shortened `1.asObservable()` to `1.obs()` (same for boolean, double, String) - [@subzero911](https://github.com/subzero911)
Expand Down
2 changes: 1 addition & 1 deletion mobx/lib/mobx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ export 'package:mobx/src/core.dart'
export 'package:mobx/src/core/atom_extensions.dart';

/// The current version as per `pubspec.yaml`
const version = '2.0.7+4';
const version = '2.0.7+5';
21 changes: 15 additions & 6 deletions mobx/lib/src/api/async/async_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AsyncAction {
}

Future<R> run<R>(Future<R> Function() body) async {
final actionInfo = _actions.startAction(name: _actions.name);
try {
return await _zone.run(body);
} finally {
Expand All @@ -33,23 +32,33 @@ class AsyncAction {
// Needed to make sure that all mobx state changes are
// applied after `await run()` completes, not sure why.
await Future.microtask(_noOp);
_actions.endAction(actionInfo);
}
}

static dynamic _noOp() => null;

R _run<R>(Zone self, ZoneDelegate parent, Zone zone, R Function() f) {
final result = parent.run(zone, f);
return result;
final actionInfo = _actions.startAction(name: '${_actions.name}(Zone.run)');
try {
final result = parent.run(zone, f);
return result;
} finally {
_actions.endAction(actionInfo);
}
}

// Will be invoked for a catch clause that has a single argument: exception or
// when a result is produced
R _runUnary<R, A>(
Zone self, ZoneDelegate parent, Zone zone, R Function(A a) f, A a) {
final result = parent.runUnary(zone, f, a);
return result;
final actionInfo =
_actions.startAction(name: '${_actions.name}(Zone.runUnary)');
try {
final result = parent.runUnary(zone, f, a);
return result;
} finally {
_actions.endAction(actionInfo);
}
}

// Will be invoked for a catch clause that has two arguments: exception and stacktrace
Expand Down
2 changes: 1 addition & 1 deletion mobx/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: mobx
version: 2.0.7+4
version: 2.0.7+5
description: "MobX is a library for reactively managing the state of your applications. Use the power of observables, actions, and reactions to supercharge your Dart and Flutter apps."

homepage: https://github.com/mobxjs/mobx.dart
Expand Down
3 changes: 2 additions & 1 deletion mobx/test/spy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void main() {
d();
});

// TODO: https://github.com/mobxjs/mobx.dart/issues/734
test('spy-event is raised only once when an AsyncAction is executed',
() async {
var eventCount = 0;
Expand Down Expand Up @@ -159,7 +160,7 @@ void main() {
expect(endEventCount, 1);

d();
});
}, skip: true);

test('spy-event is raised when a Reaction is executed', () {
final o = Observable(0);
Expand Down

0 comments on commit a55063b

Please sign in to comment.