// By id, seems to be the intended standard
const userAtom = Atom.family((id: User.Id) =>
runtimeAtom.atom(UserApi.getById(id)),
)
// Returns an effect of the atom? And would also fetch twice? Hmm...
const userAtomByDisplayId = Atom.family((displayId: string) =>
pipe(
UserApi.getByDisplayId(displayId),
Effect.map((user) => userAtom(user.id)),
),
)
// Returns an effect of an array of atoms..?
const userAtomByWorkspaceId = Atom.family((workspaceId: Workspace.Id) =>
pipe(
UserApi.getAll(workspaceId),
Effect.map(Array.map((user) => userAtom(user.id))),
),
)
// By id, seems to be the intended standard
const userAtom = Atom.family((id: User.Id) =>
runtimeAtom.atom(UserApi.getById(id)),
)
// Returns an effect of the atom? And would also fetch twice? Hmm...
const userAtomByDisplayId = Atom.family((displayId: string) =>
pipe(
UserApi.getByDisplayId(displayId),
Effect.map((user) => userAtom(user.id)),
),
)
// Returns an effect of an array of atoms..?
const userAtomByWorkspaceId = Atom.family((workspaceId: Workspace.Id) =>
pipe(
UserApi.getAll(workspaceId),
Effect.map(Array.map((user) => userAtom(user.id))),
),
)