coderwhy / hy-event-store

An event-based global state management tool for vue, react, mini-program, ect.
393 stars 45 forks source link

fix(event-store): add dispatch supports the form of Promise #32

Open Thunder7991 opened 9 months ago

Thunder7991 commented 9 months ago
 let obj = {
        funcTest: (...args) => {
            return new Promise((resolve, reject) => {
                resolve('event')
            })
        },
      };
      const dispatch = (actionName, ...args) => {
        const actionFn = obj[actionName];
        actionFn.apply(this, [1, 2, 3]);
      };

      dispatch('funcTest').then(res => {
        console.log(res);
      })

Uncaught TypeError: Cannot read properties of undefined (reading 'then') 缺少返回值