Search…
On
User events are overridden by name and weight, sorted by weight (desc) and must be namespaced.
1
class Foo {
2
3
@on('axon__task.completed', {
4
environment: 'development',
5
})
6
static check(...params, runtime) {
7
const {
8
weight,
9
source, // "script" or "event"
10
metadata,
11
event,
12
context // the event document, when fired by a user event.
13
} = runtime
14
15
console.log('checking')
16
}
17
18
}
Copied!

script.fire(event, ...params)

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 to script.arguments

@on(event, options)

Arguments
  • event { String } Event
  • options { Object } Options object
    • active { Boolean = true }
    • name { String }
    • label { String }
    • environment { String = "*" }
    • if { Expression }
    • weight { Number = 0 }

Examples

1
const { on } = require('decorators')
2
3
class Handler {
4
5
@on('axon__task.completed', { name: 'axon__task_completed_event' })
6
onCompleted( task, str ) {
7
// str === "another param"
8
}
9
10
}
11
12
const task = completeATask()
13
script.fire('axon__task.completed', task, "another param")
Copied!
Last modified 2mo ago