mattermost-redux
Version:
Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client
29 lines (28 loc) • 719 B
JavaScript
;
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Object.defineProperty(exports, "__esModule", { value: true });
class DelayedAction {
action;
timer;
constructor(action) {
this.action = action;
this.timer = null;
}
fire = () => {
this.action();
this.timer = null;
};
fireAfter = (timeout) => {
if (this.timer !== null) {
clearTimeout(this.timer);
}
this.timer = setTimeout(this.fire, timeout);
};
cancel = () => {
if (this.timer !== null) {
clearTimeout(this.timer);
}
};
}
exports.default = DelayedAction;