Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微应用监听主应用发送的消息,调用off取消监听不成功 #6959

Open
yyyyffqqqq opened this issue Jul 29, 2024 · 1 comment
Open
Labels

Comments

@yyyyffqqqq
Copy link

Describe the bug

主应用通过这两种方式给微应用传递消息:
import { store as starkDataStore, event } from '@ice/stark-data';

event?.emit(MQTT_MESSAGE, { topic, message: JSON.parse(message.toString()) });
starkDataStore?.set(MQTT_MESSAGE, { topic, message: JSON.parse(message.toString()) });

在微应用中:

starkEvent.on(MQTT_MESSAGE, ({ topic, message }) => {
      console.log('航班动态 收到主应用推送过来的消息', topic, message);
      onReceivedMqttMessage({ topic, message });
   });

starkEvent.off(MQTT_MESSAGE, () => {
        console.log('航班动态 主应用推送过来的消息监听被移除');
      });

starkEvent.off没起作用,反复执行starkEvent.on,主应用发送一次消息,会多次进入starkEvent.on的回调方法

Expected behavior

starkEvent.off(MQTT_MESSAGE, () => {
console.log('航班动态 主应用推送过来的消息监听被移除');
});
能够正常取消监听

Actual behavior

No response

Version of ice.js

"@ice/app": "3.4.10"

Content of build.json or ice.config.mts

No response

Additional context

No response

@yyyyffqqqq yyyyffqqqq added the bug label Jul 29, 2024
@ClarkXia
Copy link
Collaborator

可以提供完整的复现 demo,方便排查

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants