A problem about Recursion

The

function goes like this

const handleAddInfo = () => {
    // 
    this.props
      .dispatch({
        type: "video/setAlarmRuleEditMode",
        payload: alarmRuleEditMode.add,
      })
      .then(() => {
        this.props.dispatch({
          type: "video/setBlackListData",
          payload: {
            key: null,
          },
        });
      })
      .then(() => {
        this.props.dispatch({
          type: "video/setNaviKey",
          payload: {
            key: "addBlackList",
          },
        });
      });
  };

I want to write it as dynamic, forget to pass a few parameters automatically with several. Then, I feel that I need to use the idea of recursion, but my own idea of recursion is relatively weak. I don"t know how to write it next. I would like to ask the master to help me with some tips. Thank you very much.

    function fn(...arg) {
        arg.forEach(...)
    }
Dec.31,2021

pass any number of parameters at once

function serial (...args) {
  function runTask () {
    const arg = args.shift()
    return this.props.dispatch(arg).then(() => {
      if (args.length > 0) {
        return runTask()
      }
    })
  }
  return runTask()
}

serial(
  {
    type: 'video/setAlarmRuleEditMode',
    payload: alarmRuleEditMode.add,
  },
  {
    type: 'video/setBlackListData',
    payload: {
      key: null,
    },
  },
  {
    type: 'video/setNaviKey',
    payload: {
      key: 'addBlackList',
    },
  }
).then(() => {
    console.log('done')
})
Menu