UNPKG

@realm/react

Version:

React specific hooks and implementation helpers for Realm

30 lines 1.22 kB
import Realm from "realm"; import { AnyRealmObject } from "./helpers"; import { UseRealmHook } from "./useRealm"; type RealmClassType<T = any> = { new (...args: any): T; }; export type ObjectHookOptions<T> = { type: string; primaryKey: T[keyof T]; keyPaths?: string | string[]; }; export type ObjectHookClassBasedOptions<T> = { type: RealmClassType<T>; primaryKey: T[keyof T]; keyPaths?: string | string[]; }; export type UseObjectHook = { <T>(options: ObjectHookOptions<T>): (T & Realm.Object<T>) | null; <T extends AnyRealmObject>(options: ObjectHookClassBasedOptions<T>): T | null; <T>(type: string, primaryKey: T[keyof T], keyPaths?: string | string[]): (T & Realm.Object<T>) | null; <T extends AnyRealmObject>(type: RealmClassType<T>, primaryKey: T[keyof T], keyPaths?: string | string[]): T | null; }; /** * Generates the `useObject` hook from a given `useRealm` hook. * @param useRealm - Hook that returns an open Realm instance * @returns useObject - Hook that is used to gain access to a single Realm object from a primary key */ export declare function createUseObject(useRealm: UseRealmHook): UseObjectHook; export {}; //# sourceMappingURL=useObject.d.ts.map