-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Hello,
I noticed that when the call to context.sendTaskSuccess is a zero the result path is not getting set. The following example shows the error.
const Statebox = require('@wmfs/statebox')
const statebox = new Statebox({})
const main = async
function() {
await statebox.ready
statebox.createModuleResources({
// Simple module to add two numbers together
add: class Add {
run(event, context) {
context.sendTaskSuccess(event.number1 + event.number2)
}
},
// Simple module to subtract one number from another
subtract: class Subtract {
// Init methods are optional, but all allow
// resource-instances to be configured...
init(resourceConfig, env, callback) {
callback(null)
}
run(event, context) {
context.sendTaskSuccess(event.number1 - event.number2)
}
}
})
await statebox.createStateMachines({
'calculator': {
Comment: 'A simple calculator',
StartAt: 'Subtract',
States: {
Subtract: {
Type: 'Task',
InputPath: '$.numbers',
Resource: 'module:subtract',
ResultPath: '$.result',
End: true
}
}
}
}, {}, // 'env': An environment/context/sandbox
)
// STEP 3:
// Start a new execution on a state machine
// ----------------------------------------
const executionDescription = await statebox.startExecution({
numbers: {
number1: 3,
number2: 3
}
}, // input
'calculator', // state machine name
{} // options
)
console.log(executionDescription)
// {
// executionName: '...',
// ctx: {
// numbers': {
// number1: 3,
// number2: 2
// },
// operator: '-',
// result: 0 <--- This is not getting set in the context
// },
// }
}
if (require.main === module) {
main();
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels