Skip to content

Commit

Permalink
Correct balanced subject
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAstafyev committed Aug 16, 2023
1 parent 9e1fcc7 commit b4cdd2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions application/client/src/app/service/ilc/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@ export class Events {
}) => void
>(),
),
resize: this._add<void>(new Subject<void>()).balanced(50),
resize: this._add<void>(new Subject<void>()).balanced(25),
view: this._add<Declarations.AvailableToolbarTabs>(
new Subject<Declarations.AvailableToolbarTabs>(),
),
},
sidebar: {
min: this._add<void>(new Subject<void>()),
max: this._add<void>(new Subject<void>()),
resize: this._add<void>(new Subject<void>()).balanced(50),
resize: this._add<void>(new Subject<void>()).balanced(25),
view: this._add<Declarations.AvailableSidebarTabs>(
new Subject<Declarations.AvailableSidebarTabs>(),
),
},
window: {
resize: this._add<void>(new Subject<void>().balanced(50)),
resize: this._add<void>(new Subject<void>().balanced(25)),
},
layout: {
resize: this._add<void>(new Subject<void>()),
Expand Down
8 changes: 4 additions & 4 deletions application/platform/env/normalized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export class NormalizedBackgroundTask {
const diff = Date.now() - this.timestamp;
if (diff > this.duration) {
// This task should be done in any way - do not store timer ref
setTimeout(this.safe(task, true), 0);
setTimeout(this.safe(task), 0);
} else {
// This task could be canceled, store reference
this.timer = setTimeout(this.safe(task, false), this.duration - diff);
this.timer = setTimeout(this.safe(task), this.duration - diff);
}
}

Expand All @@ -27,13 +27,13 @@ export class NormalizedBackgroundTask {
this.controller.abort();
}

protected safe(task: () => void, untracked: boolean): () => void {
protected safe(task: () => void): () => void {
return () => {
if (this.controller.signal.aborted) {
return;
}
task();
this.timestamp = untracked ? 0 : Date.now();
this.timestamp = Date.now();
};
}
}

0 comments on commit b4cdd2d

Please sign in to comment.