@eslibs/messenger
v1.0.9
Published
A messenger
Downloads
4
Maintainers
Readme
Messenger
使用 Messenger 可以创建 Window/WebWorker/ServiceWorker/iframe 等之间的消息通道
Usage
via node
import { Messenger } from '@eslibs/messenger'
new Messenger({
listener: Function // 事件监听方法
postMessage: Function // 发送消息方法
process: Function // 消息处理方法
}).echo().listen()
via browser
<script src="https://unpkg.com/browse/[email protected]/dist/umd/uuid.min.js"></script>
<script src="https://unpkg.com/@eslibs/pipe@latest/dist/eslibs.umd.js"></script>
<script src="https://unpkg.com/@eslibs/serializer@latest/dist/eslibs.umd.js"></script>
<script src="https://unpkg.com/@eslibs/messenger@latest/dist/eslibs.umd.js"></script>
<script>
new ESLibs.Messenger({
listener: Function // 事件监听方法
postMessage: Function // 发送消息方法
process: Function // 消息处理方法
}).echo().listen()
</script>
via js module
<script type="importmap">
{
"imports": {
"uuid": "https://unpkg.com/browse/[email protected]/dist/esm-browser/index.js"
"@eslibs/pipe": "https://unpkg.com/@eslibs/pipe@latest/dist/index.es.js",
"@eslibs/serializer": "https://unpkg.com/@eslibs/serializer@latest/dist/index.es.js",
"@eslibs/messenger": "https://unpkg.com/@eslibs/messenger@latest/dist/index.es.js"
}
}
</script>
<script type="module">
import { Messenger } from '@eslibs/messenger'
new Messenger({
listener: Function // 事件监听方法
postMessage: Function // 发送消息方法
process: Function // 消息处理方法
}).echo().listen()
</script>
License
MIT