* Subscribes to any changes in the feed, return a promise * @link https://getstream.io/activity-feeds/docs/node/web_and_mobile/?language=js#subscribe-to-realtime-updates-via-api-client * @method subscribe * @memberof StreamFeed.prototype * @param {function} Faye.Callback<RealTimeMessage
(callback: Faye.SubscribeCallback<RealTimeMessage<StreamFeedGenerics>>)
| 547 | * }); |
| 548 | */ |
| 549 | subscribe(callback: Faye.SubscribeCallback<RealTimeMessage<StreamFeedGenerics>>) { |
| 550 | if (!this.client.appId) { |
| 551 | throw new SiteError( |
| 552 | 'Missing app id, which is needed to subscribe, use var client = stream.connect(key, secret, appId);', |
| 553 | ); |
| 554 | } |
| 555 | |
| 556 | const subscription = this.getFayeClient().subscribe(`/${this.notificationChannel}`, callback); |
| 557 | this.client.subscriptions[`/${this.notificationChannel}`] = { |
| 558 | token: this.token, |
| 559 | userId: this.notificationChannel, |
| 560 | fayeSubscription: subscription, |
| 561 | }; |
| 562 | |
| 563 | return subscription; |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * Cancel updates created via feed.subscribe() |
no test coverage detected