-
-
Notifications
You must be signed in to change notification settings - Fork 2
add RuntimeContext module #12
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
base: main
Are you sure you want to change the base?
Conversation
@@ -23,6 +23,7 @@ | |||
"noUnusedLocals": true, | |||
"noUnusedParameters": false, | |||
"noFallthroughCasesInSwitch": true, | |||
"jsx": "react", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use "preserve"
since it's expected to go through bundling.
Otherwise it's better to use "react-jsx"
since it's more compatible with non-react jsx (unintuitively)
Though all-in-all. We don't have any jsx in the project so we can remove this altogether
export interface RuntimeContext<R> extends ReactContext<R> { | ||
readonly [RuntimeContextTypeId]: { | ||
readonly scope: Scope.CloseableScope | ||
readonly context: Effect.Effect<never, never, Context.Context<R>> | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we want to ride the ReactContext
like that. It's mostly likely safe, but it's an eye raising pattern 🤔
Effect.cached, | ||
Effect.runSync | ||
) | ||
Effect.runFork(runtime) // prime cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will very likely break in ssr environments 🤔
const resultBag = useSyncExternalStore( | ||
storeRef.current.subscribe, | ||
storeRef.current.snapshot | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3rd argument for SSR. Maybe just return a static Initial
until we figure out the serverside?
@@ -21,6 +23,19 @@ describe("useResult", () => { | |||
expect(Result.isSuccess(result.current.result)).toBe(true) | |||
}) | |||
|
|||
it("override Provider value", async () => { | |||
const [Override] = RuntimeContext.overrideLayer(context, Layer.succeed(foo, { value: 2 })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern feels "unnatural" in react settings. We need to think if we want to do this or something else..
No description provided.