定时器换回了node-schedule

This commit is contained in:
Xu Chang 2023-03-01 18:06:35 +08:00
parent 529e8a4a63
commit a15f026fc9
3 changed files with 6 additions and 4 deletions

View File

@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDebugStore = exports.clearMaterializedData = void 0;
var tslib_1 = require("tslib");
var cron_1 = require("oak-domain/lib/utils/cron");
var node_schedule_1 = require("node-schedule");
var constant_1 = require("../constant/constant");
var DebugStore_1 = require("./DebugStore");
var actionDef_1 = require("oak-domain/lib/store/actionDef");
@ -274,7 +274,7 @@ function initializeTimers(store, contextBuilder, timers) {
}
var _loop_1 = function (timer) {
var cron = timer.cron, fn = timer.fn, name_1 = timer.name;
(0, cron_1.schedule)(cron, function (date) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
(0, node_schedule_1.scheduleJob)(name_1, cron, function (date) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var start, context, result, err_2;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

View File

@ -12,6 +12,7 @@
"debounce": "^1.2.1",
"format-message-parse": "^6.2.4",
"history": "^5.3.0",
"node-schedule": "^2.1.1",
"oak-common-aspect": "file:../oak-common-aspect",
"oak-domain": "file:../oak-domain",
"oak-memory-tree-store": "file:../oak-memory-tree-store",
@ -45,6 +46,7 @@
"@types/luxon": "^2.0.9",
"@types/mocha": "^8.2.0",
"@types/node": "^14.14.25",
"@types/node-schedule": "^2.1.0",
"@types/react": "^18.0.12",
"@types/react-dom": "^18.0.5",
"@types/uuid": "^8.3.0",

View File

@ -1,4 +1,4 @@
import { schedule } from 'oak-domain/lib/utils/cron';
import { scheduleJob } from 'node-schedule';
import { LOCAL_STORAGE_KEYS } from '../constant/constant';
import { DebugStore } from './DebugStore';
import {
@ -203,7 +203,7 @@ function initializeTimers<ED extends EntityDict & BaseEntityDict, Cxt extends As
}
for (const timer of timers) {
const { cron, fn, name } = timer;
schedule(cron, async (date) => {
scheduleJob(name, cron, async (date) => {
const start = Date.now();
const context = await contextBuilder()(store);
await context.begin();