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

Add an example to https://www.effect.website/docs/faq#configuring-layers #207

Open
steida opened this issue Jul 19, 2023 · 0 comments
Open

Comments

@steida
Copy link

steida commented Jul 19, 2023

For example, that's what I have in Evolu. Note EvoluLive(schema) vs ReactLive.
The Layer is like a constructor without a new, if I understand it properly. Hence PascalCase. Am I correct?

const Live = <From, To extends Schema>(
  schema: S.Schema<From, To>,
  config?: Partial<Config>
): Layer.Layer<never, never, React<Schema>> =>
  ConfigLive(config).pipe(
    Layer.provide(EvoluLive(schema)),
    Layer.provide(ReactLive)
  );

export const create = <From, To extends Schema>(
  schema: S.Schema<From, To>,
  config?: Partial<Config>
): React<To>["hooks"] =>
  React.pipe(
    Effect.map((react) => react.hooks as React<To>["hooks"]),
    Effect.provideLayer(Live<From, To>(schema, config)),
    Effect.runSync
  );
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