Using Effect with React Without Exposing Internals for Global Configuration
Hi!
I'm using Effect to write the logic and state of an in-house library which encapsulates a bunch of our business logic.
The goal is to expose a React component that the calling application can render, there's no exposing the Effect internals of those React components. This is because we have multiple applications which need to use these components, and a lot of our service client libraries are written using Effect.
We already have a bunch of ways of running Effects in a React component context with a single runtime across all the runs - basically, a bunch of hooks that run Effects in different ways depending on what the component needs, where all the hooks share a single ManagedRuntime.
Getting to the point - the library needs to be configured with the URLs for services it needs to call. We usually manage this by exposing an Effect Service that can be provided by the application with the correct configuration, which works very nicely. However, here as I mentioned we aren't exposing any of the Effect internals because the interface will be a React component. Ideally, the user would pass in the configuration as props, and then in the parent component I could set the configuration a single time, and those values would be used across the entire application.
I have an inkling that a FiberRef could be used to do something like this, I believe that's how things like the log level and concurrency level are set, and I know that will be 'inherited' by child fibers. What I don't know is if there's a way of setting the 'new fiber default' for a FiberRef 'globally' on the runtime after the runtime has been constructed already - or, of course, if there's some other way of doing what I want.
Any ideas? Thanks in advance!
I'm using Effect to write the logic and state of an in-house library which encapsulates a bunch of our business logic.
The goal is to expose a React component that the calling application can render, there's no exposing the Effect internals of those React components. This is because we have multiple applications which need to use these components, and a lot of our service client libraries are written using Effect.
We already have a bunch of ways of running Effects in a React component context with a single runtime across all the runs - basically, a bunch of hooks that run Effects in different ways depending on what the component needs, where all the hooks share a single ManagedRuntime.
Getting to the point - the library needs to be configured with the URLs for services it needs to call. We usually manage this by exposing an Effect Service that can be provided by the application with the correct configuration, which works very nicely. However, here as I mentioned we aren't exposing any of the Effect internals because the interface will be a React component. Ideally, the user would pass in the configuration as props, and then in the parent component I could set the configuration a single time, and those values would be used across the entire application.
I have an inkling that a FiberRef could be used to do something like this, I believe that's how things like the log level and concurrency level are set, and I know that will be 'inherited' by child fibers. What I don't know is if there's a way of setting the 'new fiber default' for a FiberRef 'globally' on the runtime after the runtime has been constructed already - or, of course, if there's some other way of doing what I want.
Any ideas? Thanks in advance!
