File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ See the [official Pub/Sub API repo](https://github.com/developerforce/pub-sub-ap
1212- [ Basic Example] ( #basic-example )
1313- [ Other Examples] ( #other-examples )
1414 - [ Publish a platform event] ( #publish-a-platform-event )
15+ - [ Subscribe to an infinite number of events] ( #subscribe-to-an-infinite-number-of-events )
1516 - [ Subscribe with a replay ID] ( #subscribe-with-a-replay-id )
1617 - [ Subscribe to past events in retention window] ( #subscribe-to-past-events-in-retention-window )
1718 - [ Handle gRPC stream lifecycle events] ( #handle-grpc-stream-lifecycle-events )
@@ -264,6 +265,25 @@ const publishResult = await client.publish('/event/Sample__e', payload);
264265console.log('Published event: ', JSON.stringify(publishResult));
265266` ` `
266267
268+ ### Subscribe to an infinite number of events
269+
270+ You may subscribe to an infinite number of events by reconnecting the client automatically when the last requested event is received.
271+
272+ ` ` ` js
273+ // Handle last requested event
274+ subscription.on('lastevent', async () => {
275+ try {
276+ // Re-subscribe to more events
277+ subscription = await client.subscribe(
278+ subscription.getTopicName(),
279+ NUMBER_OF_EVENTS
280+ );
281+ } catch (error) {
282+ console.log(error);
283+ }
284+ });
285+ ` ` `
286+
267287### Subscribe with a replay ID
268288
269289Subscribe to 5 account change events starting from a replay ID :
You can’t perform that action at this time.
0 commit comments