@gluecodes/orchiee
v0.1.9
Published
Action orchestrator
Downloads
11
Readme
Orchiee
Framework-agnostic action orchestrator with an awesome type support
Installation
npm install --save @gluecodes/orchiee
Usage
import * as Fn from '@gluecodes/orchiee';
const someAction = async (): SomeType => {}
const observedSomeAction = Fn.be(someAction)
Fn.observe(Fn.calling(observedSomeAction), (isBeingCalled) => {
// isBeingCalled is Boolean type
})
Fn.observe(Fn.called(observedSomeAction), (itsReturnedValue) => {
// itsReturnedValue is SomeType and it's taken from someAction
})
Fn.observe(Fn.failed(observedSomeAction), (error) => {
// error is Error type
})
Fn.observe(Fn.called(observedSomeAction, Fn.called(action1), Fn.called(action2)), (itsReturnedValue) => {
// when action1() or action2() is triggered, this callback is triggered
})
// on cleanup of your framework
Fn.cleanup() // clears all listeners