vue-wait icon indicating copy to clipboard operation
vue-wait copied to clipboard

mapWaitingActions

Open YanCore opened this issue 5 years ago • 1 comments

Currently mapWaitingActions(vuexModuleName, actions), intercepts actions, the default waiter's name is the same as the action name(for example, mapWaitingActions('users', ['list']), waiter is list) but if vuexModuleName is set, it is actually hoped to use the name Space is isolated. I hope that mapWaitingActions provides vuexModuleName, and the default waiter name is the of vuexModuleName/action.

YanCore avatar Sep 20 '19 03:09 YanCore

When mapWatingActions intercepts an action, I want to format the waiter from args. In this way, when the list item is modified or deleted, the list item that is modified and deleted can be uniquely identified, and the list item is separately loaded.

    if (action) {
      mappings[method] = async function(...args) {
        try {
         // actionName='fetch'
         // const {id} = args
         // watier='$_users/fetch/{{id}}'
         // something like this: 
         // this.__$waitInstance.start(waiter.format(args));
          this.__$waitInstance.start(waiter);
          return await this.$store.dispatch(
            vuexModuleName ? `${vuexModuleName}/${action}` : action,
            ...args
          );
        } finally {
          this.__$waitInstance.end(waiter);
        }
      };
    }

YanCore avatar Sep 20 '19 03:09 YanCore