Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (action-manager) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
action-manager
Action-Manager is a framework for defining, invoking, and integrating actions.
Visit Action-Manager for more information.
🚧 Under Construction 🚧
We will be incrementally uploading our entire framework over the new few months.
Install
yarn add action-manager
npm install action-manager
Usage
Creating an action
const printTime: Action = {
handler: () => console.log(new Date().toISOString())
}
Invoking an action (without context)
await invoke(printTime)
Invoking an action with context
await invoke(printTime,
{
// These are the targets of the action
targets: [],
// These are the parameters
params: {type: 'log'},
// This is the environment
env: {timeZone: 'EST'}
}
)
Benefits
- Eliminate boilerplate code
- Increase reusability
- Access a rich ecosystem of shared libraries
Features
- Plugin based system for confirmation dialogs
- Generate user interfaces
- Dynamic labels support
- Fully asynchronous
- Action pipelines
- No dependencies
Creating Actions
The only required property in the Action interface is the handler
.
Handlers accept a single argument: the context
.
const printTime: Action = {
handler: () => console.log(new Date().toISOString())
}
The power of action-manager emerges as you begin to implement the optional properties.
const printTime: Action = {
id: 'print_time',
name: 'Print Time',
description: 'Print the current time, in ISO format, to the console.'
log: true,
handler: () => console.log(new Date().toISOString())
}
The action can now be used to generate user interface items, such as buttons and menu items.
Invoking Actions
There are many advantages to invoking an action instead of directly calling its handler.
[todo list advantages]
[todo show examples]
Action Widgets
There are several types of action widgets. These widgets are implemented using several libraries.
- Buttons
- Menu Items
- Spreadsheets
- External API
Action Context
A context object is provided to the action handler as it's only parameter.
The context is also provided to MaybeRef
properties.
There are three parts to the action context:
- Targets
- Parameters
- Environment
Target
The target is the object or objects the action is to be performed on. Actions indicate the cardinality of the targets they perform on. For instance, a delete action may work on 1 or more targets, while a compare action may require exactly two.
Parameters
Parameters are properties that indicate on how the action should go about acting on the targets for a particular invocation.
Environment
The environment are common properties that typically remain the same for multiple actions.
Action Registry
[todo]
Developer
TODO
- Remove Vue dependency
- Create driver for prompts and errors
- Create driver for logging
- Organize for various UI frameworks
Testing
yarn test
Building
yarn build