Events APIs
Event APIs provide access to POS Events. Each event accepts a subscriber function as an argument and returns an unsubscribe function. Every time the event occurs, POS calls the subscriber function. The unsubscribe function can be evaluated in order to unsubscribe from an event.
Note that POS calls subscribers in a blocking fashion, waiting for each subscriber to resolve.
Example:
// Create a subscriber const subscriber = order => { console.log(‘Finalized an order with total’, order.total); }; // Subscribe to the POS event and save a reference to the unsubscribe function const unsubscribe = api.events.order.onOrderFinalized(subscriber); //… // Unsubscribe from the event. unsubscribe();