Skip to content

Commit

Permalink
feat: add option to disable transition in solid integration
Browse files Browse the repository at this point in the history
  • Loading branch information
XiNiHa committed Oct 11, 2024
1 parent afe944b commit 6802e68
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions integrations/solid/src/__internal__/core/CoreProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ export const CoreStateContext = createContext<{

export interface CoreProviderProps {
coreStore: CoreStore;
transition: boolean;
children: JSXElement;
}
export const CoreProvider: Component<CoreProviderProps> = (props) => {
const [stack, setStack] = createStore(props.coreStore.actions.getStack());
const [pending, startTransition] = useTransition();

props.coreStore.subscribe(() => {
startTransition(() => {
const update = () =>
setStack(reconcile(props.coreStore.actions.getStack(), { merge: true }));
});
if (props.transition) startTransition(update);
else update();
});

return (
Expand Down
1 change: 1 addition & 0 deletions integrations/solid/src/future/StackComponentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import type { Component } from "solid-js";
export type StackComponentType = Component<{
initialContext?: any;
initialLoaderData?: any;
transition?: boolean;
}>;
5 changes: 4 additions & 1 deletion integrations/solid/src/future/stackflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ export function stackflow<
return (
<ConfigProvider value={input.config}>
<PluginsProvider value={coreStore.pluginInstances}>
<CoreProvider coreStore={coreStore}>
<CoreProvider
coreStore={coreStore}
transition={props.transition ?? true}
>
<MainRenderer
activityComponentMap={input.components}
initialContext={initialContext()}
Expand Down
6 changes: 5 additions & 1 deletion integrations/solid/src/stable/stackflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useStepActions } from "./useStepActions";

export type StackComponentType = Component<{
initialContext?: any;
transition?: boolean;
}>;

type StackflowPluginsEntry<T extends BaseActivities> =
Expand Down Expand Up @@ -197,7 +198,10 @@ export function stackflow<T extends BaseActivities>(

return (
<PluginsProvider value={coreStore.pluginInstances}>
<CoreProvider coreStore={coreStore}>
<CoreProvider
coreStore={coreStore}
transition={props.transition ?? true}
>
<MainRenderer
activityComponentMap={activityComponentMap}
initialContext={props.initialContext}
Expand Down

0 comments on commit 6802e68

Please sign in to comment.