title: EventChannel
sidebar_label: EventChannel
Inter-page event communication channel
Methods
emit
Trigger an event
Reference
(eventName: string, ...args: any) => void
| Property |
Type |
Description |
| eventName |
string |
event name |
| args |
any |
event arguments |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| EventChannel.emit |
✔️ |
|
✔️ |
off
Cancels listening to an event. If the second parameter is passed, only the specified listener is cancelled, otherwise all listener functions are cancelled.
Reference
(eventName: string, fn: EventCallback) => void
| Property |
Type |
Description |
| eventName |
string |
event name |
| fn |
EventCallback |
event handler |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| EventChannel.off |
✔️ |
|
on
Register a listener event
Reference
(eventName: string, fn: EventCallback) => void
| Property |
Type |
Description |
| eventName |
string |
event name |
| fn |
EventCallback |
event handler |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| EventChannel.on |
✔️ |
|
once
Register a listener event that expires after being triggered once.
Reference
(eventName: string, fn: EventCallback) => void
| Property |
Type |
Description |
| eventName |
string |
event name |
| fn |
EventCallback |
event handler |
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| EventChannel.once |
✔️ |
|
API Support
| API |
WeChat Mini-Program |
H5 |
React Native |
| EventChannel.emit |
✔️ |
|
|
| EventChannel.off |
✔️ |
|
|
| EventChannel.on |
✔️ |
|
|
| EventChannel.once |
✔️ |
|
|