cicada-message
For cicada iframe post message
Usage
import createMesssage from '@cicada/message'
const { listen, dispatch, invoke } = createMesssage()
listen('yourMessage', (data) => {
})
dispatch('yourMessage', { data: 'data' })
invoke('yourMessage', { data: 'data' }, 10000).then(result => console.log(result))
API
- listen(event, callback) 监听事件
- dispatch(event, data, toParent) 远程触发事件
- invoke(vent, data, timeout, toParent) 远程服务调用并直接返回