You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JavaScript's Promise library provides Promise.try() as a static method primarily for the purpose of folding error handling of "before the async stuff starts" code into the async model, so that the developer doesn't need to handle both sync and async errors:
returnPromise.try(()=>{// do some sync work that could throw an errorreturnsomeSynchronousValue}).then((value)=>{// use the value, do some async work});
or
returnPromise.try(()=>{// do some sync work that could throw an errorreturnstartAsyncPromise()}).then((value)=>{// use the value});
These cases correspond neatly to Future's map(to:) and flatMap(to:) methods - I propose adding static variations, like so:
JavaScript's
Promise
library providesPromise.try()
as a static method primarily for the purpose of folding error handling of "before the async stuff starts" code into the async model, so that the developer doesn't need to handle both sync and async errors:or
These cases correspond neatly to
Future
'smap(to:)
andflatMap(to:)
methods - I propose adding static variations, like so:or
The text was updated successfully, but these errors were encountered: