Actions
register actions with Dashboard.
How to register an Action?
Action object:
{
id: '@plugin_bundle-my-awesome-action',
description: 'My awesome action, to handle awesome things!',
action: () => {// My awesome action}
}register
import { Plugin } from '@root'
export default class MyAgent extends Plugin.Agent {
constructor(props) {
super(props)
const myActions = [
{
id: 'my-logger-action',
description: 'A logger action to style logs outputs',
action: this._logger.bind(this)
},
{
id: 'my-fetch-action',
description: 'A fetch action to handle fetch requests',
action: this._fetch.bind(this)
}
]
this.registerActions(actions)
}
_logger(message) {
console.log('=====')
console.log(message)
console.log('=====')
}
_fetch(url) {
return new Promise((resolve, reject) => {
this.request(url).then(resp => resp.json()).then(data => {
resolve(data)
}).catch(error => {
reject(error)
})
})
}
}How to use an Action?
getActionLast updated