Skip to content

Commit afd2a37

Browse files
jasnellFlarna
andauthored
Apply suggestions from code review
Co-authored-by: Gerhard Stöbich <[email protected]>
1 parent e1f1ffb commit afd2a37

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

doc/contributing/erm-guidelines.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ exclusive ownership of the object. A disposable object can become disposed
8282
at any time.
8383

8484
The `Symbol.dispose` and `Symbol.asyncDispose` methods are called in both
85-
successful and exceptional exits from the scopes in which the using keyword
85+
successful and exceptional exits from the scopes in which the `using` keyword
8686
is used. This means that if an exception is thrown within the scope, the
8787
disposal methods will still be called. However, when the disposal methods are
8888
called they are not aware of the context. These methods will not receive any
@@ -144,7 +144,10 @@ A disposable object can be quite simple:
144144

145145
```js
146146
class MyResource {
147+
#disposed = false;
147148
dispose() {
149+
if (this.#disposed) return;
150+
this.#disposed = true;
148151
console.log('Resource disposed');
149152
}
150153

@@ -399,5 +402,3 @@ class MyDisposable {
399402
Because of this, it is important to consider the possible relationships
400403
between disposable objects. For example, if one disposable object holds a
401404
reference to another disposable object the cleanup order may be important.
402-
If disposers are properly idempotent, however, this should not cause any
403-
issue, but it still requires careful consideration.

0 commit comments

Comments
 (0)