Skip to content

Commit

Permalink
🥁don't provide np-ops
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejpurves committed Sep 4, 2023
1 parent a053a4f commit bf91f51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions packages/react/src/ThebeServerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ type ListenerFn = (data: ThebeEventData) => void;

export const ThebeServerContext = React.createContext<
| {
connecting: boolean;
ready: boolean;
config?: Config;
events?: ThebeEvents;
server?: ThebeServer;
connecting: boolean;
ready: boolean;
connect: () => void;
disconnect: () => Promise<void>;
connect?: () => void;
disconnect?: () => Promise<void>;
}
| undefined
>(undefined);
Expand Down Expand Up @@ -144,7 +144,10 @@ export function useThebeServer() {
const { core } = thebe ?? {};

const serverContext = useContext(ThebeServerContext);
const { config, events, server, connecting, ready, connect, disconnect } = serverContext ?? {};
const { config, events, server, connecting, ready, connect, disconnect } = serverContext ?? {
ready: false,
connecting: false,
};

const [error, setError] = useState<string | undefined>(); // TODO how to handle errors better via the provider
const [eventCallbacks, setEventCallbacks] = useState<ThebeEventCb[]>([]);
Expand Down Expand Up @@ -192,5 +195,5 @@ export function useThebeServer() {
subscribe,
unsubAll,
}
: {};
: { connecting: false, ready: false };
}
6 changes: 3 additions & 3 deletions packages/react/src/ThebeSessionProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ interface ThebeSessionContextData {
path?: string;
session?: ThebeSession;
error?: string;
starting?: boolean;
ready?: boolean;
starting: boolean;
ready: boolean;
start?: () => Promise<void>;
shutdown?: () => Promise<void>;
}
Expand Down Expand Up @@ -104,5 +104,5 @@ export function ThebeSessionProvider({

export function useThebeSession(): ThebeSessionContextData {
const sessionContext = useContext(ThebeSessionContext);
return sessionContext ?? {};
return sessionContext ?? { starting: false, ready: false };
}

0 comments on commit bf91f51

Please sign in to comment.