diff --git a/src/ui/react/hooks/index.ts b/src/ui/react/hooks/index.ts index 2d14f69..764e76b 100644 --- a/src/ui/react/hooks/index.ts +++ b/src/ui/react/hooks/index.ts @@ -1,31 +1,19 @@ import type { DebugConfig, FullDB } from "../../../core"; import type { ReactType } from "../types"; +import type { + Changer, + MassUpdater, + MassUpdaterInternal, + Updater, + UpdaterInternal, +} from "./types"; + +export type { MassUpdater, Updater } from "./types"; function flat(list: T[][]): T[] { return list.reduce((a, b) => a.concat(b)); } -type MassUpdaterInternal = ( - options: {}, - kind: K, - id: string, - delta: (prev: Domain[K]) => Domain[K] -) => void; -export type MassUpdater = MassUpdaterInternal< - Domain, - K -> & { - (kind: K, id: string, delta: (prev: Domain[K]) => Domain[K]): void; -}; - -type UpdaterInternal = (options: {}, delta: (prev: T) => T) => void; -export type Updater = UpdaterInternal & { - (delta: (prev: T) => T): void; -} & (T extends {} - ? { (field: K, value: T[K]): void } - : {}); -type Changer = [T | "loading", Updater]; - function makeMassUpdater( db: FullDB ): MassUpdater { diff --git a/src/ui/react/hooks/types.ts b/src/ui/react/hooks/types.ts new file mode 100644 index 0000000..df2b169 --- /dev/null +++ b/src/ui/react/hooks/types.ts @@ -0,0 +1,20 @@ +export type MassUpdaterInternal = ( + options: {}, + kind: K, + id: string, + delta: (prev: Domain[K]) => Domain[K] +) => void; +export type MassUpdater = MassUpdaterInternal< + Domain, + K +> & { + (kind: K, id: string, delta: (prev: Domain[K]) => Domain[K]): void; +}; + +export type UpdaterInternal = (options: {}, delta: (prev: T) => T) => void; +export type Updater = UpdaterInternal & { + (delta: (prev: T) => T): void; +} & (T extends {} + ? { (field: K, value: T[K]): void } + : {}); +export type Changer = [T | "loading", Updater];