How to control the socket link established by the subscriptions of dva to run after obtaining certain data

subscriptions: {
    socketGetMessage({ dispatch }) {
      return getMessage(data => {
        const datajson = JSON.parse(data);
        dispatch({
          type: "notice/fetch_mqtt_add",
          payload: datajson
        });
      });
    }
 }
The method in

subscriptions executes

when app.start ()

let client;
export async function getMessage(action) {client = connect(mqttUrl, {
    clientId: terminalUid,
    ...mqttSetting // 
  });

  client.on("connect", () => {
       console.log(":" + client.connected);
  });

  client.on("message", (topic, message, packet) => {
    action(message.toString());
  });
}
    

but the user configuration parameters needed to establish a socket link need to asynchronously request an API to get
, while subscriptions executes
when dom ready. Is there any good way to get the user"s setting parameter and then initiate a socket connection

?
Mar.02,2021

Open a websocket in subscriptions .
and then trigger a effects in onmessage of websocket .

Menu