本文整理汇总了TypeScript中@feathersjs/feathers.Application.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Application.on方法的具体用法?TypeScript Application.on怎么用?TypeScript Application.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@feathersjs/feathers.Application
的用法示例。
在下文中一共展示了Application.on方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (app: Application) => {
app.configure(channels());
app.configure(routing());
app.on('publish', getDispatcher(emit, socketKey));
// `connection` event
done.then(provider => provider.on('connection', (connection: any) =>
app.emit('connection', getParams(connection)))
);
// `socket.emit('methodName', 'serviceName', ...args)` handlers
done.then(provider => provider.on('connection', (connection: any) => {
for (const method of app.methods) {
connection.on(method, (...args: any[]) => {
const path = args.shift();
debug(`Got '${method}' call for service '${path}'`);
runMethod(app, getParams(connection), path, method, args);
});
}
}));
// Legacy `socket.emit('serviceName::methodName', ...args)` handlers
app.mixins.push((service, path) => done.then(provider => {
provider.on('connection', (socket: any) => {
const methods = app.methods.filter(current =>
// @ts-ignore
typeof service[current] === 'function'
);
for (const method of methods) {
const eventName = `${path}::${method}`;
socket.on(eventName, (...args: any[]) => {
debug(`Got legacy method call '${eventName}'`);
runMethod(app, getParams(socket), path, method, args);
});
}
});
}));
};