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
In the above conversation, we discussed the problem of creating an Effect from a Promise<Either<E, D>>. Initially, there was a suggestion to use Effect.promiseEither or Effect.runPromiseExit to achieve this. However, it was pointed out that it might be better to create a wrapper or utility function to handle the client and convert the result into an Effect directly.
The suggested approach was to create a wrapper function that encapsulates the Supabase client creation and query execution. This wrapper function would return an object with methods for executing queries. By using this wrapper function, you can directly return an Effect without having to manually convert the Promise<Either<E, D>> result.
The key takeaways from this conversation are:
Encapsulate complexity in a single place by creating a wrapper function or utility to handle external APIs or services.
Use the wrapper function to directly return an Effect instead of manually converting the Promise<Either<E, D>> result.
By encapsulating complexity, you can easily mock the external API or service for testing purposes.
Avoid the XY problem by focusing on solving the original issue rather than looking for a specific method or solution.
The text was updated successfully, but these errors were encountered:
mikearnaldi
changed the title
From Discord: Creating an Effect from a Promise<Either<E,D>>
From Discord: Possible Docs example on using external libraries with Effect
Jan 10, 2024
Summary
In the above conversation, we discussed the problem of creating an
Effect
from aPromise<Either<E, D>>
. Initially, there was a suggestion to useEffect.promiseEither
orEffect.runPromiseExit
to achieve this. However, it was pointed out that it might be better to create a wrapper or utility function to handle the client and convert the result into anEffect
directly.The suggested approach was to create a wrapper function that encapsulates the Supabase client creation and query execution. This wrapper function would return an object with methods for executing queries. By using this wrapper function, you can directly return an
Effect
without having to manually convert thePromise<Either<E, D>>
result.The key takeaways from this conversation are:
Effect
instead of manually converting thePromise<Either<E, D>>
result.Discord thread
https://discord.com/channels/795981131316985866/1194569368445665340
The text was updated successfully, but these errors were encountered: