Skip to content

Commit

Permalink
fix(jotai): Change GuestAtom to AsyncAtom (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyp3rflow authored Aug 18, 2022
1 parent 337276f commit a752f9d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/jotai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createWrpGuest, WrpGuest } from "../guest.ts";

export type SocketAtom = Atom<Promise<Socket | undefined>>;
export type ChannelAtom = Atom<WrpChannel | undefined>;
export type GuestAtom = Atom<WrpGuest | undefined>;
export type GuestAtom = Atom<Promise<WrpGuest> | undefined>;
export type ClientImplAtom = Atom<RpcClientImpl | undefined>;
export interface WrpAtomSet {
channelAtom: ChannelAtom;
Expand All @@ -19,15 +19,15 @@ export interface WrpAtomSet {
export function createWrpAtomSet(socketAtom: SocketAtom): WrpAtomSet {
interface ChannelAndGuest {
channel: WrpChannel;
guest: WrpGuest;
guest: Promise<WrpGuest>;
}
const channelAndGuestAtom = atom<Promise<ChannelAndGuest | undefined>>(
async (get) => {
const socket = get(socketAtom);
if (!socket) return;
const realChannel = createWrpChannel(socket);
const listeners: ((message?: WrpMessage) => void)[] = [];
const guest = await createWrpGuest({
const guest = createWrpGuest({
channel: {
...realChannel,
async *listen() {
Expand Down

0 comments on commit a752f9d

Please sign in to comment.