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
To generate interoperability between the synchronous and asynchronous monads in the library.
How will this change help?
This change will help concatenate synchronous and asynchronous calls by transforming an Either into a Future. This way, we won’t need to manually map the call; instead, by invoking the method, we make it asynchronous, allowing us to use async maps.
Screenshots
No response
How could it be implemented/designed?
Here's an example case:
it.each([{type: 'Right',either: Either.right(2),syncClosure: (x: number)=>x*2,asyncClosure: async(x: number)=>x*2,expected: 8,},])('$type should handle map with another async map operation correctly',async({ either, syncClosure, asyncClosure, expected })=>{either.map(syncClosure).toFuture().map(asyncClosure).complete(async(value)=>expect(awaitvalue).toEqual(expected),async(error)=>expect(error).toBeUndefined());});
Where in abstract class we add:
// abstract class Either<L, R>abstracttoFuture(): Future<R|L>;
And in its implementations:
// class Left<L, R>toFuture(): Future<L>{returnFuture.of(()=>Promise.resolve(this.value));}
// class Right<L, R>toFuture(): Future<R>{returnFuture.of(()=>Promise.resolve(this.value));}
Why do we need this improvement?
To generate interoperability between the synchronous and asynchronous monads in the library.
How will this change help?
This change will help concatenate synchronous and asynchronous calls by transforming an Either into a Future. This way, we won’t need to manually map the call; instead, by invoking the method, we make it asynchronous, allowing us to use async maps.
Screenshots
No response
How could it be implemented/designed?
Here's an example case:
Where in abstract class we add:
And in its implementations:
🚧 Breaking changes
No
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue?
Yes I am willing to submit a PR!
The text was updated successfully, but these errors were encountered: