This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-js/lib/src/native/notification.js

19 lines
648 B
JavaScript
Raw Normal View History

2020-01-08 19:44:24 +08:00
export function notification(context) {
return {
publish: (args) => {
if (args.data !== undefined) {
args.data = JSON.stringify(args.data);
}
return context.callNative('notification', 'publish', args);
2020-01-08 19:44:24 +08:00
},
subscribe: (args) => {
args.callback = context.function2Id(args.callback);
return context.callNative('notification', 'subscribe', args);
2020-01-08 19:44:24 +08:00
},
unsubscribe: (subscribeId) => {
context.removeFuncById(subscribeId);
return context.callNative('notification', 'unsubscribe', subscribeId);
2020-01-08 19:44:24 +08:00
}
};
}