-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Labels
Milestone
Description
Deferred API work as callback where we must call resolve or reject method.
{
get("/deferred", promise(deferred -> {
deferred.resolve("OK");
}));
}This programming model makes perfect sense to integrate reactive/async libraries like rx, reactor, etc... but is kind of verbose for using within an Executor:
{
executor(new ForkJoinPool());
get("/deferred", promise(deferred -> {
deferred.resolve("OK");
}));
}When we could just write:
{
executor(new ForkJoinPool());
get("/deferred", deferred(() -> {
return "OK";
}));
}If an error occurs while resolving the value, we automatically catch the exception and call reject.
This is just more syntax sugar, no major change is required.