Notification API

安装

npm install @cutos/core

引入依赖

import {CoreAPI} from '@cutos/core';

CoreAPI.getNotification

获取通知信息实例对象

let notification = CoreAPI.getNotification();

notification.register

注册通知监听函数

notification.register(listener)
  • listener: 监听函数
举例:
notification.register((data) => {
  console.log(data);
})
  • 返回结果示例:
{
  "event": "networkConnection",
  "msg": true
}
  • event: 事件名称
  • msg: 事件内容

notification.unregister

取消注册,用于取消notification.register的注册

notification.unregister()

notification.emit

取消注册,用于取消notification.register的注册

notification.emit(event, msg)
  • event: 事件名称
  • msg: 事件内容
举例:
import {CoreAPI} from '@cutos/core';

CoreAPI.init();

let notification = CoreAPI.getNotification();
notification.register((data) => {
  console.log(data);
})
notification.emit('notification-1', 'msg-1')
  • 返回结果示例:
{
  "event": "notification-1",
  "msg": "msg-1"
}

系统通知

网络状态通知
{
  "event": "networkConnection",
  "msg": true
}
  • networkConnection: 网络状态通知
  • true: 在线; false: 离线

results matching ""

    No results matching ""