js subscribe异步函数 返回异步的结果

套一个promise即可,XXXXX是具体的函数,根据实际情况套用

export const getType = async () => {
  let type= '';
  return new Promise((resolve) => {
    XXXXX.subscribe((ctx: any) => {
      ctx.subscribe((data) => {
        type= data.type|| '';
      });
    });
    resolve(type);
  });
};