-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing the PresenceStore #330
Conversation
this.handleRemoteChange() | ||
} | ||
// Update timestamp for this cache key | ||
this.timestamps[key] = new Date() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just use Date.now()
instead of an actual Date
since you won't actually be using any of the date functionality
performPurge = () => { | ||
const now = new Date() | ||
Object.keys(this.states).forEach(key => { | ||
const age = now - this.timestamps[key].timestamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think timestamp
is a standardized property, but as pointed out earlier, a Date.now()
would skip the need for this
this.connection = connection | ||
this.unsubscribeListener = this.connection.listen().subscribe(this.handleMessage).unsubscribe | ||
this.myState = {} | ||
this.states = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use an ES6 Map
for states and timestamps instead? It is more suitable for arbitrary keys, IIRC.
this.unsubscribeListener() | ||
clearTimeout(this.resendReportTimer) | ||
clearInterval(this.performPurgeTimer) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple more timers that should be closed here, I think? changeReportDebounceTimer
for instance
…ate.now() instead of new Date()
Implements the store to support the real time presence experience in a Sanity studio.