fix(core): update

This commit is contained in:
2020-07-12 02:40:45 +00:00
parent cb85deeb3d
commit 5fa7312171
5 changed files with 46 additions and 44 deletions

View File

@ -4,3 +4,4 @@ export { Taskparallel } from './taskbuffer.classes.taskparallel';
export { TaskManager } from './taskbuffer.classes.taskmanager';
export { TaskOnce } from './taskbuffer.classes.taskonce';
export { TaskRunner } from './taskbuffer.classes.taskrunner';
export { TaskDebounced } from './taskbuffer.classes.taskdebounced';

View File

@ -0,0 +1,25 @@
import * as plugins from './taskbuffer.plugins';
import { Task, ITaskFunction } from './taskbuffer.classes.task';
export class TaskDebounced<T = unknown> extends Task {
private _debouncedTaskFunction: ITaskFunction;
private _observableIntake = new plugins.smartrx.ObservableIntake<T>();
constructor(optionsArg: {
name: string;
taskFunction: ITaskFunction;
type: 'atMostEvery' | 'afterQuietFor'
}) {
super({
name: optionsArg.name,
taskFunction: async (x: T) => {
this._observableIntake.push(x);
}
});
this.taskFunction = optionsArg.taskFunction;
this._observableIntake.observable.pipe(plugins.smartrx.rxjs.ops.debounceTime(2000)).subscribe((x) => {
this.taskFunction(x);
});
}
}

View File

@ -2,6 +2,7 @@ import * as smartlog from '@pushrocks/smartlog';
import * as lik from '@pushrocks/lik';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartrx from '@pushrocks/smartrx';
import * as smarttime from '@pushrocks/smarttime';
export { smartlog, lik, smartpromise, smartdelay, smarttime };
export { smartlog, lik, smartpromise, smartdelay, smartrx, smarttime };