@ovok/core/next/react
Generated reference for @ovok/core/next/react.
- Stable unknown
- Release candidate since 0.4.49-rc.4
- Development since 0.4.49-dev.517+4645a0a
Type Aliases
OvokMutation
type OvokMutation<TVariables, TResult> = (client, variables) => Promise<TResult>;A function that writes with the client, given the variables passed to mutate.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
client | Ovok |
variables | TVariables |
Returns
Promise<TResult>
OvokMutationState
type OvokMutationState<TVariables, TResult> = object;The state returned by useOvokMutation.
Type Parameters
Properties
OvokProviderProps
type OvokProviderProps = React.PropsWithChildren<{
client: Ovok;
}>;Props for OvokProvider.
OvokQuery
type OvokQuery<T> = (client, signal) => Promise<T>;A function that reads data with the client; it receives an abort signal.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
client | Ovok |
signal | AbortSignal |
Returns
Promise<T>
OvokQueryOptions
type OvokQueryOptions = object;Options for useOvokQuery.
Properties
| Property | Type | Description |
|---|---|---|
enabled? | boolean | Set false to skip the query; defaults to true. |
queryKey | readonly unknown[] | Identifies the query; the query runs again when it changes. |
OvokQueryState
type OvokQueryState<T> = object;The state returned by the query hooks.
Type Parameters
Properties
Functions
OvokProvider()
function OvokProvider(__namedParameters): ReactElement;Makes client available to the hooks in its subtree.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | OvokProviderProps |
Returns
ReactElement
Example
<OvokProvider client={ovok}><App /></OvokProvider>useOvok()
function useOvok(): Ovok;Returns the Ovok client from the nearest OvokProvider.
Returns
Throws
Error when used outside an OvokProvider.
useOvokMutation()
function useOvokMutation<TVariables, TResult>(mutation): OvokMutationState<TVariables, TResult>;Wraps a write so a component can call it and track its loading, error and data state.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
mutation | OvokMutation<TVariables, TResult> |
Returns
OvokMutationState<TVariables, TResult>
Example
const { mutate } = useOvokMutation((ovok, patient) => ovok.fhir.create(patient));useOvokQuery()
function useOvokQuery<T>(query, options): OvokQueryState<T>;Runs query and tracks its loading, error and data state; it runs again when options.queryKey changes.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
query | OvokQuery<T> |
options | OvokQueryOptions |
Returns
Example
const { data, loading } = useOvokQuery((ovok, signal) => ovok.health.check({ signal }), { queryKey: ["health"] });useProfile()
function useProfile(): OvokQueryState<OvokReference | null>;Returns the signed-in profile reference, or null when signed out.
Returns
OvokQueryState<OvokReference | null>
useResource()
function useResource<K>(
type,
id,
options?
): OvokQueryState<ExtractResource<K>>;Reads one FHIR resource by id; skipped while id is undefined.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
type | K |
id | string | undefined |
options? | Pick<OvokQueryOptions, "enabled"> |
Returns
OvokQueryState<ExtractResource<K>>
useSearch()
function useSearch<K>(
type,
params?,
options?
): OvokQueryState<Page<ExtractResource<K>>>;Searches a FHIR resource type and returns the first page.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
type | K |
params? | QueryParams |
options? | Pick<OvokQueryOptions, "enabled"> |
Returns
OvokQueryState<Page<ExtractResource<K>>>
useSession()
function useSession(): OvokQueryState<Session | null>;Returns the current session, or null when signed out, and updates when the session changes.
Returns
OvokQueryState<Session | null>
useSubscription()
function useSubscription<T>(subscribe): T | undefined;Subscribes to a source of values and returns the latest one, or undefined before the first.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
subscribe | (listener) => () => void |
Returns
T | undefined
Last updated on