Skip to content

Commit

Permalink
replace debounce with later/cancel in cookie store (#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoow authored Jan 24, 2017
1 parent 3ae3242 commit c416797
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions addon/session-stores/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
RSVP,
computed,
inject: { service },
run: { next, debounce, scheduleOnce },
run: { next, scheduleOnce, cancel, later },
isEmpty,
typeOf,
testing,
Expand Down Expand Up @@ -68,6 +68,9 @@ const persistingProperty = function(beforeSet = function() {}) {
@public
*/
export default BaseStore.extend({
_syncDataTimeout: null,
_renewExpirationTimeout: null,

/**
The domain to use for the cookie, e.g., "example.com", ".example.com"
(which includes all subdomains) or "subdomain.example.com". If not
Expand Down Expand Up @@ -240,7 +243,8 @@ export default BaseStore.extend({
this.trigger('sessionDataUpdated', data);
}
if (!testing) {
debounce(this, this._syncData, 500);
cancel(this._syncDataTimeout);
this._syncDataTimeout = later(this, this._syncData, 500);
}
});
},
Expand All @@ -257,7 +261,8 @@ export default BaseStore.extend({

_renewExpiration() {
if (!testing) {
debounce(this, this._renewExpiration, 60000);
cancel(this._renewExpirationTimeout);
this._renewExpirationTimeout = later(this, this._renewExpiration, 60000);
}
if (this.get('_isPageVisible')) {
return this._renew();
Expand Down

0 comments on commit c416797

Please sign in to comment.