-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handling async results #75
Comments
It requires work but let me look into it! |
It is also actual for my case. It will be better to have the possibility to handle the async methods with chained construction. Thanks |
You can see how |
It's an interesting one, because in a way you could also just use What I am trying to say is that you could simply do... const validateParams = async (params): Promise<UserAttributes> => {
...
}
const insertUser = async (attrs: UserAttributes): Promise<User> => {
const { id, firstName, lastName, insertedAt } = await db.insert(attrs)
return { id, firstName, lastName, insertedAt }
}
const user = validateParams(params).then(insertUser) ...which would be conceptually equivalent to However, if there is a use-case where |
@slavovojacek From my point of view, the only advantage of Also, with a |
Hi,
A lot of my methods return a
Promise<Result<T,K>>
because they handle async behaviour (writing to the database for instance).I would love to be able to chain these methods with
and_then
but the latter only accepts methods that return aResult<T,K>
.Example:
Is this possible currently or does this require additional work ?
I'm willing to help if I can.
Cheers
The text was updated successfully, but these errors were encountered: