on-native-event-receive.js 328 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import {
  isFn
}
  from 'uni-shared'

const callbacks = []

export function onNativeEventReceive (callback) {
  isFn(callback) &&
    callbacks.indexOf(callback) === -1 &&
    callbacks.push(callback)
}

export function consumeNativeEvent (event, data) {
  callbacks.forEach(callback => callback(event, data))
}