Skip to content
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

From Discord: Possible Docs example on using external libraries with Effect #430

Open
effect-bot opened this issue Jan 10, 2024 · 0 comments

Comments

@effect-bot
Copy link

Summary

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:

  1. Encapsulate complexity in a single place by creating a wrapper function or utility to handle external APIs or services.
  2. Use the wrapper function to directly return an Effect instead of manually converting the Promise<Either<E, D>> result.
  3. By encapsulating complexity, you can easily mock the external API or service for testing purposes.
  4. Avoid the XY problem by focusing on solving the original issue rather than looking for a specific method or solution.

Discord thread

https://discord.com/channels/795981131316985866/1194569368445665340

@mikearnaldi 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant