Skip to content

Installation

Install

sh
npm install act-master

When installing, act-master-cli is included as a dependency. It is small and does not participate in runtime — it helps with code generation during development.

Initialize the project

Run the init command and follow the prompts. It will create a .act-master.yaml config file used to find *.act.ts files and generate the actions index.

sh
npx act-master-cli init

If you accepted the defaults, you also get an example error-handler action — OnError.act.ts.

Bootstrap

ts
import { createApp } from 'vue';
import App from './App.vue'

import { VueActMaster, type ActMasterOptions } from 'act-master/vue';
import { actions } from '@/act/actions';

const options: ActMasterOptions = {
  actions,
  // If you used the default error file on init:
  errorHandlerEventName: 'OnError',
};

createApp(App)
  .use(VueActMaster, options)
  .mount('#app');
ts
import { act, type ActMasterOptions } from 'act-master';
import { actions } from '@/act/actions';

const options: ActMasterOptions = {
  actions,
  errorHandlerEventName: 'OnError',
};

act.init(options);
ts
import { ActMaster, type ActMasterOptions } from 'act-master';
import { actions } from '../act/actions';

const options: ActMasterOptions = {
  actions,
  errorHandlerEventName: 'OnError',
};

const $act = new ActMaster(options);
ts
import Vue from 'vue';
import App from './App.vue';

import { VueActMaster, type ActMasterOptions } from 'act-master/vue';
import { actions } from '@/act/actions';

const options: ActMasterOptions = {
  actions,
  errorHandlerEventName: 'OnError',
};

Vue.use(VueActMaster, options);

new Vue({
  render: h => h(App),
}).$mount('#app');

ActMasterOptions

PropertyDefaultDescription
actions?: ActMasterAction[][]Array of action instances
errorHandlerEventName?: ActEventNameundefinedAction name to call on uncaught error
di?: DIMap{}Dependency injection map
autoUnsubscribeCallbackundefinedHook for plugin-level auto-unsubscribe

Now all that's left to do is: