Skip to content

Commit

Permalink
Added a refresh method to the Lock class
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed May 23, 2017
1 parent e4e2208 commit e90274f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/resource/lock/Lock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export declare class Lock {
user: IUser;
constructor(lockKind: LockKind, user: IUser, owner: LockOwner);
expired(): boolean;
refresh(timeout?: number): void;
}
3 changes: 3 additions & 0 deletions lib/resource/lock/Lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ var Lock = (function () {
Lock.prototype.expired = function () {
return Date.now() > this.expirationDate;
};
Lock.prototype.refresh = function (timeout) {
this.expirationDate += timeout ? timeout : this.lockKind.timeout;
};
return Lock;
}());
exports.Lock = Lock;
5 changes: 5 additions & 0 deletions src/resource/lock/Lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ export class Lock
{
return Date.now() > this.expirationDate;
}

refresh(timeout ?: number)
{
this.expirationDate += timeout ? timeout : this.lockKind.timeout;
}
}

0 comments on commit e90274f

Please sign in to comment.