-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: add debounce and sample on subjects for performance
- Loading branch information
Showing
6 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
import { BehaviorSubject } from 'rxjs' | ||
import { debounceTime, sampleTime } from 'rxjs/operators' | ||
|
||
const DEBOUNCE_TIME = 50 | ||
const SAMPLE_TIME = 500 | ||
|
||
export const ConnectionStatusSubject = new BehaviorSubject<boolean>(false) | ||
export const SyncedBlockNumberSubject = new BehaviorSubject<string>('0') | ||
|
||
export default { ConnectionStatusSubject, SyncedBlockNumberSubject } | ||
export const DebouncedConnectionStatusSubject = ConnectionStatusSubject.pipe(debounceTime(DEBOUNCE_TIME)) | ||
export const SampledSyncedBlockNumberSubject = SyncedBlockNumberSubject.pipe(sampleTime(SAMPLE_TIME)) | ||
|
||
export default { | ||
ConnectionStatusSubject, | ||
SyncedBlockNumberSubject, | ||
DebouncedConnectionStatusSubject, | ||
SampledSyncedBlockNumberSubject, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { BehaviorSubject } from 'rxjs' | ||
import { debounceTime } from 'rxjs/operators' | ||
|
||
const systemScriptSubject = new BehaviorSubject<{ codeHash: string }>({ codeHash: '' }) | ||
const DEBOUNCE_TIME = 50 | ||
|
||
export default systemScriptSubject | ||
export const SystemScriptSubject = new BehaviorSubject<{ codeHash: string }>({ codeHash: '' }) | ||
export const DebouncedSystemScriptSubject = SystemScriptSubject.pipe(debounceTime(DEBOUNCE_TIME)) | ||
|
||
export default { SystemScriptSubject, DebouncedSystemScriptSubject } |