本文整理汇总了TypeScript中@feathersjs/feathers.Application.channel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Application.channel方法的具体用法?TypeScript Application.channel怎么用?TypeScript Application.channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@feathersjs/feathers.Application
的用法示例。
在下文中一共展示了Application.channel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('promise event dispatching', done => {
app.channel('testing').join(c1);
app.channel('othertest').join(c2);
app.service('test').registerPublisher('created', () =>
new Promise(resolve =>
setTimeout(() => resolve(app.channel('testing')), 50)
)
);
app.service('test').registerPublisher('created', () =>
new Promise(resolve =>
setTimeout(() => resolve(app.channel('testing', 'othertest')), 100)
)
);
app.once('publish', (_event: string, channel: Channel, hook: HookContext) => {
assert.deepStrictEqual(hook.result, data);
assert.deepStrictEqual(channel.connections, [ c1, c2 ]);
done();
});
app.service('test')
.create(data)
.catch(done);
});
示例2: it
it('.leave all child channels conditionally', () => {
const c1 = { id: 1 };
const c2 = { id: 2, leave: true };
const combined = app.channel('test', 'again').join(c1, c2);
combined.leave((connection: RealTimeConnection) => connection.leave);
assert.strictEqual(app.channel('test').length, 1);
assert.strictEqual(app.channel('again').length, 1);
});