Appearance
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
| Parameter | Type | Description |
|---|---|---|
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()getAppConfig()
Retrieves the configuration for the calling app. App name can be optionally provided, otherwise it will be derived from the caller's URL.
Parameters
| Parameter | Type |
|---|---|
payload? | { app_name: string; } |
payload.app_name? | string |
Returns
Example
ts
dsrApi.getAppConfig() // for self config
// or with explicit app name
dsrApi.getAppConfig({ app_name: 'my-app' })getEnv()
Fetches the necessary info for the app to know where it is embedded.
Check out usePitcherApi().getEnv() for more information.
Returns
Example
ts
useDsr().getEnv()getFile()
Fetches a file by ID.
Parameters
| Parameter | Type |
|---|---|
payload | { id: string; } |
payload.id | string |
Returns
Example
ts
dsrApi.getFile({ id: 'my-file-id' })