MCPcopy Create free account
hub / github.com/GetStream/stream-js / subscribe

Method subscribe

src/feed.ts:549–564  ·  view source on GitHub ↗

* 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>>)

Source from the content-addressed store, hash-verified

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()

Callers 5

faye_test.jsFile · 0.80
doneYetFunction · 0.80
subFunction · 0.80
throwsFunction · 0.80
feed_test.jsFile · 0.80

Calls 1

getFayeClientMethod · 0.95

Tested by

no test coverage detected