Async actions on a rule's onSuccess?
See original GitHub issueHi, I noticed that promises were not being observed on an onSuccess of rule callback. Seems this way in the code as well. Is there a workaround to this?
Also, what I may be struggling with is the approach to using rules-engines in general and wanting the truthy state of a rule to fire off an action and update the event parameters with the results. Is there a better approach to this?
{
conditions: {
all: [
{
fact: 'result',
path: '.parameters.email',
operator: 'notEqual',
value: ''
}
]
},
event: { },
onSuccess: ((event, almanac) => {
return almanac.factValue('result')
.then((result) => {
// Do something async. Rule engine completes run before this action completes.
})
})
}
Thanks, Steve
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Asynchronous execution and onsuccess event handler
Because Javascript is strictly single-threaded, asynchronous operations can only run their callbacks once other code has finished running.
Read more >Understanding the Event Loop, Callbacks, Promises, and ...
An async function can handle a promise called within it using the await operator. await can be used within an async function and...
Read more >Async Await JavaScript Tutorial – How to Wait for a Function to ...
Failing to provide the async keyword will result in a syntax error when trying to use await inside a regular function.
Read more >Async Actions | Enact
It allows an action creator to return a function instead of an object (action) and executes that function when it is returned. This...
Read more >Asynchronous Programming in Java - Baeldung
Since Java 5, the Future interface provides a way to perform asynchronous operations using the FutureTask. We can use the submit method of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@daxiang28 Ya, it’d be nice if there was a more elegant solution. If you think of a feature request that would make this easier, please feel free to file it. For now I’ll close this issue as it appears you’ve found a workaround
@CacheControl yes that’s pretty much what I’ve rejiggered my code to. The one last piece I was hoping to figure out without being so hacky is mutating the rule event params in the success-events array