Skip to content

Commit

Permalink
Enhance GC in events.
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcean committed Sep 12, 2024
1 parent 2771a8d commit caedd52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datasense",
"version": "2.2.0",
"version": "2.3.0",
"description": "A set of powerful utilities and classes for accessing and observing data.",
"main": "index.js",
"types": "./index.d.ts",
Expand Down
11 changes: 9 additions & 2 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ export class EventObservable implements DisposableArrayContract {
};
let implInstance = this._instance;
implInstance.push(key, obj);
let disposableResult: DisposableContract = {} as any;
let result: EventRegisterResultContract<T> = {
get key() {
return key;
Expand All @@ -617,10 +618,16 @@ export class EventObservable implements DisposableArrayContract {
dispose() {
implInstance.remove(key, obj);
disposableList.dispose();
disposableResult.dispose = () => { };
}
};
implInstance.pushDisposable(result);
if (disposableArray) disposableArray.pushDisposable(result);
disposableResult.dispose = () =>
{
result.dispose();
disposableResult.dispose = () => { };
};
implInstance.pushDisposable(disposableResult);
if (disposableArray) disposableArray.pushDisposable(disposableResult);
return result;
}

Expand Down

0 comments on commit caedd52

Please sign in to comment.