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
Hi! It's really a neat and lightweight libs.
I wonder if EitherAsync.chain can support both Either and EitherAsync?
For example, if I want to chain getTitle, I need add async in the chain method.
Or any recommendations for handling this? Thanks.
asyncfunctiongetPost(postId: number): Promise<Either<Error,Post>>{constresponse=awaitfetch(`/posts/${postId}`);returnresponse
? Right((response.json()asunknown)asPost)
: Left(newError(`Problem fetching post with id: ${postId}`));}functiongetTitle(post: Post): Either<Error,string>{returnpost.title
? Right(post.title)
: Left(newError("This post should have a title"));}functiongetPostTitle(req: Request): EitherAsync<Error,string>{returnEitherAsync.liftEither(validateRequest(req)).chain((request)=>getPost(request.postId)).chain(async(post)=>getTitle(post));}
The text was updated successfully, but these errors were encountered:
Hi! It's really a neat and lightweight libs.
I wonder if
EitherAsync.chain
can support bothEither
andEitherAsync
?For example, if I want to chain
getTitle
, I need addasync
in the chain method.Or any recommendations for handling this? Thanks.
The text was updated successfully, but these errors were encountered: