-
Notifications
You must be signed in to change notification settings - Fork 1
Notifications
DummyAPI notifications are based on Socket.io library and support handling in two directions: from server, to server.
Current topic is about basics of notifications.
Any changes of any resource instance trigger sending events to client. By default next events are send for corresponding changes in resources:
- resource_created - resource instance is created.
- resource_updates - resource instance is changed.
- resource_deleted - resource instance is removed.
Affected resource instance is sent as body of event.
For sure, your application "understands" differ events, than DummyAPI sends. To tune events triggered by resource changes use proxy function. It is set on the "To Client" tab of notifications panel.
Notifications Proxy Function - is triggered to pre-process event object before sending it to client. It can tune name and body of the event. Proxy function gets event object as first parameter and data as second. Result of it should be event object:
{
name: String, // event name
type: 'msg' || 'event', // type of response
data: Any, // event body
}
Event object passed to function contains default name and type.
NOTE: proxy function MUST have name 'proxy'
You can send custom notification to selected client by full filling "Send Notifications" form.
Switch to "From Client" tab of Notifications panel to see what events your application is sending to a server.