From a56f67fdabb132e32d48c397587188a1ee535382 Mon Sep 17 00:00:00 2001 From: Minsu Lee Date: Wed, 6 Jul 2022 10:35:25 +0900 Subject: [PATCH] fix: revert #784 --- mobx/CHANGELOG.md | 4 ++++ mobx/lib/mobx.dart | 2 +- mobx/lib/src/api/async/async_action.dart | 21 +++++++++++++++------ mobx/pubspec.yaml | 2 +- mobx/test/spy_test.dart | 3 ++- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mobx/CHANGELOG.md b/mobx/CHANGELOG.md index 603c9b4c4..ec3209550 100644 --- a/mobx/CHANGELOG.md +++ b/mobx/CHANGELOG.md @@ -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) diff --git a/mobx/lib/mobx.dart b/mobx/lib/mobx.dart index 9d380ddef..ec0c8b577 100644 --- a/mobx/lib/mobx.dart +++ b/mobx/lib/mobx.dart @@ -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'; diff --git a/mobx/lib/src/api/async/async_action.dart b/mobx/lib/src/api/async/async_action.dart index e93f8aa62..0f8872986 100644 --- a/mobx/lib/src/api/async/async_action.dart +++ b/mobx/lib/src/api/async/async_action.dart @@ -24,7 +24,6 @@ class AsyncAction { } Future run(Future Function() body) async { - final actionInfo = _actions.startAction(name: _actions.name); try { return await _zone.run(body); } finally { @@ -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(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( 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 diff --git a/mobx/pubspec.yaml b/mobx/pubspec.yaml index 849907ae5..392a399ef 100644 --- a/mobx/pubspec.yaml +++ b/mobx/pubspec.yaml @@ -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 diff --git a/mobx/test/spy_test.dart b/mobx/test/spy_test.dart index 264f49d72..485e826e4 100644 --- a/mobx/test/spy_test.dart +++ b/mobx/test/spy_test.dart @@ -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; @@ -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);