Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
I like the Option pattern here but if saveUser throws, fa won't catch it because it hasn't been called yet. This requires saveUser to contain try/catch logic.
Could this be resolved by fa taking a function as a param, instead?
Hm? fa takes a promise, so it's all good. In the example, saveUser is returning a promise - no try/catch necessary there. You can check out the source (12 lines) and the tests to see examples github.com/craigmichaelmartin/fawait
Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
I like the Option pattern here but if
saveUser
throws,fa
won't catch it because it hasn't been called yet. This requiressaveUser
to contain try/catch logic.Could this be resolved by
fa
taking a function as a param, instead?Hm?
fa
takes a promise, so it's all good. In the example,saveUser
is returning a promise - no try/catch necessary there. You can check out the source (12 lines) and the tests to see examples github.com/craigmichaelmartin/fawaitDerp! Yup, I forgot it takes a promise, even when it was shown right above
saveUser
returns a promise :)Nice utility 👍