38 lines
833 B
TypeScript
38 lines
833 B
TypeScript
import { MinPriorityQueue } from '@datastructures-js/priority-queue';
|
|
import { Arrays } from '../../../browser/tools/Arrays';
|
|
import { DateHelper } from '../../../browser/date/DateHelper';
|
|
import { DateMath } from '../../../browser/date/DateMath';
|
|
|
|
export class Task
|
|
{
|
|
id:string;
|
|
userID:string;
|
|
appID:string;
|
|
date:Date;
|
|
action:()=>void;
|
|
|
|
setUserContext( appID:string, userID:string )
|
|
{
|
|
this.appID = appID;
|
|
this.userID = userID;
|
|
|
|
return this;
|
|
}
|
|
|
|
static createIn( id:string, duration:number, action:()=>void )
|
|
{
|
|
let date = DateMath.fromNowAddSeconds( duration );
|
|
return Task.createAt( id, date, action );
|
|
}
|
|
|
|
static createAt( id:string, date:Date, action:()=>void )
|
|
{
|
|
let task = new Task();
|
|
|
|
task.id = id;
|
|
task.action = action;
|
|
task.date = date;
|
|
|
|
return task;
|
|
}
|
|
} |