File tree Expand file tree Collapse file tree 3 files changed +35
-10
lines changed Expand file tree Collapse file tree 3 files changed +35
-10
lines changed Original file line number Diff line number Diff line change 13
13
14
14
### Semantic Versioning
15
15
16
- > ** This library is still pre-1.0.0.**
17
- >
18
- > Patches and minor changes will be released in a patch version, while breaking
19
- > changes can be released in a minor version.
20
-
21
16
- [ ] ** Patch**
22
17
- [ ] This change does not affect the public API
23
18
- [ ] This change fixes existing incorrect behavior without any additions
19
+ - [ ] ** Minor**
24
20
- [ ] This change adds something to the public API
25
21
- [ ] This change deprecates a part of the public API
26
- - [ ] ** Minor **
22
+ * [ ] Major
27
23
- [ ] This change modifies part of the public API in a backwards-incompatible manner
28
24
- [ ] This change removes part of the public API
29
25
30
-
31
26
### Testing/QA
32
27
33
28
- [ ] CI passes
34
29
35
-
36
30
### Code Review
37
31
38
- @dustinlessard-wf @evanweible-wf @jayudey-wf @maxwellpeterson-wf @sebastianmalysa-wf @trentgrover-wf
32
+ @dustinlessard-wf
33
+ @evanweible-wf
34
+ @jayudey-wf
35
+ @maxwellpeterson-wf
36
+ @sebastianmalysa-wf
37
+ @trentgrover-wf
38
+
Original file line number Diff line number Diff line change @@ -113,6 +113,20 @@ abstract class Disposable implements _Disposable {
113
113
/// Whether this object has been disposed.
114
114
bool get isDisposed => _didDispose.isCompleted;
115
115
116
+ /// Whether this object has been disposed or is disposing.
117
+ ///
118
+ /// This will become `true` as soon as the [dispose] method is called
119
+ /// and will remain `true` forever. This is intended as a convenience
120
+ /// and `object.isDisposedOrDisposing` will always be the same as
121
+ /// `object.isDisposed || object.isDisposing` .
122
+ bool get isDisposedOrDisposing => isDisposed || isDisposing;
123
+
124
+ /// Whether this object is in the process of being disposed.
125
+ ///
126
+ /// This will become `true` as soon as the [dispose] method is called
127
+ /// and will become `false` once the [didDispose] future completes.
128
+ bool get isDisposing => _isDisposing;
129
+
116
130
/// Dispose of the object, cleaning up to prevent memory leaks.
117
131
@override
118
132
Future <Null > dispose () async {
@@ -191,6 +205,7 @@ abstract class Disposable implements _Disposable {
191
205
192
206
Null _completeDisposeFuture (List <dynamic > _) {
193
207
_didDispose.complete ();
208
+ _isDisposing = false ;
194
209
return null ;
195
210
}
196
211
Original file line number Diff line number Diff line change @@ -40,8 +40,18 @@ class DisposableThing extends Object with Disposable {
40
40
41
41
@override
42
42
Future <Null > onDispose () {
43
+ expect (isDisposed, isFalse);
44
+ expect (isDisposing, isTrue);
45
+ expect (isDisposedOrDisposing, isTrue);
43
46
wasOnDisposeCalled = true ;
44
- return new Future (() {});
47
+ var future = new Future <Null >(() => null );
48
+ future.then ((_) async {
49
+ await new Future (() {}); // Give it a chance to update state.
50
+ expect (isDisposed, isTrue);
51
+ expect (isDisposing, isFalse);
52
+ expect (isDisposedOrDisposing, isTrue);
53
+ });
54
+ return future;
45
55
}
46
56
}
47
57
You can’t perform that action at this time.
0 commit comments