Notification API
CoreAPI.getNotification
Get notification information instance object
let notification = CoreAPI.getNotification();
notification.register
Register notification listener function
notification.register(listener)
- listener: listener function
Example:
notification.register((data) => {
console.log(data);
})
- Return result example:
{
"event": "networkConnection",
"msg": true
}
- event: event name
- msg: event content
notification.unregister
Unregister, used to cancel the registration of notification.register
notification.unregister()
notification.emit
Cancel registration, used to cancel the registration of notification.register
notification.emit(event, msg)
- event: event name
- msg: event content
Example:
import {CoreAPI} from '@cutos/core';
CoreAPI.init();
let notification = CoreAPI.getNotification();
notification.register((data) => {
console.log(data);
})
notification.emit('notification-1', 'msg-1')
- Return result example:
{
"event": "notification-1",
"msg": "msg-1"
}
System notification
Network status notification
{
"event": "networkConnection",
"msg": true
}
- networkConnection: Network status notification
- true: online; false: offline