我有像
这样的生成器功能function* subscribe(action) {
const topic = action.payload;
client.subscribe(topic);
yield put(MqttActions.onConnect(connected));
client.onMessageArrived = (message) => {
console.log('MESSAGE==',message.payloadString);
//yield put(MqttActions.onMessageArrived(message));
};
yield put(MqttActions.onMessageArrived(client.onMessageArrived));
client.onConnectionLost = (responseObject) => {
console.log({ responseObject });
//yield put(MqttActions.onConnectionLost(responseObject));
};
}
export default function* mSagas() {
yield all([fork(takeLatest, MqttActions.CONNECTING, connection)]);
yield all([fork(takeLatest, MqttActions.SUBSCRIBE, subscribe)]);
}
我的问题在这里我无法在side client.onMessageArrived =(message)=>中产生put(MqttActions.onMessageArrived(message))。 {}如何使用yield这里可以在client.onMessageArrived发生时调度动作,这是怎么做的