Skip to content

Commit

Permalink
configurable throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan committed Oct 4, 2023
1 parent 02e02cc commit 1a678d4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core-manager/replication-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import { throttle } from 'throttle-debounce'
export class ReplicationState extends TypedEmitter {
/** @type {Map<string, CoreReplicationState>} */
#coreStates = new Map()
#handleUpdate

#handleUpdate = throttle(200, function () {
this.emit('state', this.getState())
}).bind(this)
constructor({ throttleMs = 200 } = {}) {
super()
this.#handleUpdate = throttle(throttleMs, function () {
this.emit('state', this.getState())
}).bind(this)
}

getState() {
const state = {
Expand Down

0 comments on commit 1a678d4

Please sign in to comment.