Skip to content

Function: useDsr()

useDsr(): object

API methods available in the CatalogIQ default UI.

You can store the API object in a variable and call the methods directly.

Most methods have a snake_case and camelCase version of their name available.

ts
import { useDsr } from '@pitcher/js-api'

const dsrApi = useDsr()

Returns

object

on()

on: (type, handler) => Promise<() => void>

Subscribe to a given event type by its key.

Parameters

ParameterTypeDescription
type"dsr_env_changed"The event type/key to subscribe to.
handler(data) => Promise<void>The handler function to call when the event is emitted.

Returns

Promise<() => void>

A Promise resolving to a cleanup function to unsubscribe from the event.

close()

Closes the already open file that was opened via api or by the user.

Returns

Promise<void>

Example

ts
dsrApi.close()

embeddableReady()

Signal to DSR that the app is ready to be shown.

Returns

Promise<void>

Example

ts
useDsr().embeddableReady()

getEnv()

Fetches the necessary info for the app to know where it is embedded.

Check out usePitcherApi().getEnv() for more information.

Returns

Promise<DsrEnv>

Example

ts
useDsr().getEnv()

getFile()

Fetches a file by ID.

Parameters

ParameterType
payload{ id: string; }
payload.idstring

Returns

Promise<File>

Example

ts
dsrApi.getFile({ id: 'my-file-id' })