当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript agenda.define函数代码示例

本文整理汇总了TypeScript中agenda.define函数的典型用法代码示例。如果您正苦于以下问题:TypeScript define函数的具体用法?TypeScript define怎么用?TypeScript define使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了define函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Agenda

///<reference path="agenda.d.ts"/>

import * as Agenda from "agenda";


var mongoConnectionString = "mongodb://127.0.0.1/agenda";

var agenda = new Agenda({ db: { address: mongoConnectionString } });
 
 
agenda.define('delete old users', (job, done) => {

});

agenda.on('ready', () => {
    agenda.every('3 minutes', 'delete old users');
 
    // Alternatively, you could also do: 
    agenda.every('*/3 * * * *', 'delete old users');

    agenda.start();
});

agenda.define('send email report', { priority: 'high', concurrency: 10 }, (job, done) => {
});

agenda.on('ready', () => {
    agenda.schedule('in 20 minutes', 'send email report', { to: 'admin@example.com' });
    agenda.start();
});
开发者ID:0815fox,项目名称:DefinitelyTyped,代码行数:30,代码来源:agenda-tests.ts

示例2: callback

        return callback(null, true);
    }
});

io.sockets.on('connection', socket => {
    console.log("user connected");
    socket.emit('helloWorld', { hello: 'world' });
    socket.on('refreshRepos', data => {
        let url = `https://api.github.com/users/${data && data.user}/repos`;
        request(url, { json: true, headers: { 'user-agent': 'node.js' } }, (err, response, data) => {
            socket.emit('reposRefreshed', data)
        });
    });
});


// test agenda job scheduler
var mongoConnectionString = "mongodb://localhost/agenda";

var agenda = new Agenda({ db: { address: mongoConnectionString } });

agenda.define('test', (job, done) => {
    console.log('agenda test');
    done();
});

agenda.on('ready', () => {
    agenda.every('10 minutes', 'test');

    agenda.start();
});
开发者ID:Dev-I-Ant,项目名称:full-featured-skeleton,代码行数:31,代码来源:server.ts


注:本文中的agenda.define函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。