@6river/loopback2-component-pubsub 中文文档教程
loopback2-component-pubsub
将 pubsub 客户端注入全局应用程序对象的环回 v2.x 组件。
与 Loopback /change-stream 通道的主要区别在于,此实现只为每个模型创建两个观察者(保存后和删除后),然后将更改流式传输到保持活动状态的注册连接。 相反,Loopback 为每个 连接创建了两个相同的观察者。
Install and Setup
安装公司: npm install --save loopback2-component-pubsub
将以下配置添加到 component-config.json:
{
...
"loopback2-component-pubsub": {
"projectId": "my-project",
...
},
...
}
Usage
使用 app.pubsub
字段访问 pubsub 客户端。
loopback2-component-pubsub
Loopback v2.x component that injects pubsub client into the global app object.
The main difference with Loopback /change-stream channels is that this implementation creates only two observers (after save and after delete) per model and then streams the changes to keep-alive registered connections. In contrast Loopback creates two same observers for each connection.
Install and Setup
Install the company: npm install --save loopback2-component-pubsub
Add the following configuration to component-config.json:
{
...
"loopback2-component-pubsub": {
"projectId": "my-project",
...
},
...
}
Usage
Access pubsub client using app.pubsub
field.