On
User events are overridden by name and weight, sorted by weight (desc) and must be namespaced.
class Foo {
@on('axon__task.completed', {
environment: 'development',
})
static check(...params, runtime) {
const {
weight,
source, // "script" or "event"
metadata,
event,
context // the event document, when fired by a user event.
} = runtime
console.log('checking')
}
}
Execute events registered with
@on
in the same script context as the current principal.Arguments
event
{ String[] } The custom event name. eg.axon__task.completed.before
...params
{ *[] } Options object to pass toscript.arguments
Arguments
event
{ String } Eventoptions
{ Object } Options objectactive
{ Boolean = true }name
{ String }label
{ String }environment
{ String = "*" }if
{ Expression }weight
{ Number = 0 }
const { on } = require('decorators')
class Handler {
@on('axon__task.completed', { name: 'axon__task_completed_event' })
onCompleted( task, str ) {
// str === "another param"
}
}
const task = completeATask()
script.fire('axon__task.completed', task, "another param")
Last modified 2yr ago