subscribe and pull.
How It Works
- When a subscription is created, a
stateis generated and stored. It allows pulling events starting from the subscription time. - When events are pulled, the
stateis used to generate events since the state was created, as well as the new state for the next pull.
Configuration Example
Functions
subscribe
File:<event-type>-subscribe.<ext>, for example created-subscribe.js
The subscribe method initializes the subscription to events and retrieves a unique identifier for future pulls.
Arguments:
parameters– object, parameters (matchingparametersSchema) of this particular data collection.
state– object, subscription state. This state will be saved and passed asstateto thepullfunction.
pull
File:<event-type>-pull.<ext>, for example created-pull.js
The pull method fetches records based on the subscription and stores them in the state.It also generates events for each created, updated, or deleted record. Arguments:
state– object, state returned fromsubscribefunction.parameters– object, parameters (matchingparametersSchema) of this particular data collection.
events– list of objects representing events withtypeandrecordfields.state– updated state information, including the new information for subsequent pulls.