UNPKG

obsidian-dev-utils

Version:

This is the collection of useful functions that you can use for your Obsidian plugin development

38 lines (37 loc) 1.3 kB
/** * @packageDocumentation * * Provides a utility to retrieve the Obsidian `App` instance. */ import type { App } from 'obsidian'; /** * Wrapper type for storing shared state in the Obsidian app. */ export declare class ValueWrapper<T> { value: T; /** * Creates a new value wrapper. * * @param value - The value to wrap. */ constructor(value: T); } /** * Retrieves the Obsidian `App` instance. * * @returns The `App` instance. * @throws Will throw an error if the `App` instance cannot be found. * * @see {@link https://github.com/mnaoumov/obsidian-codescript-toolkit?tab=readme-ov-file#obsidianapp-module} * @deprecated Usage of this function is not recommended. Pass the {@link App} instance to the function instead when possible. */ export declare function getApp(): App; /** * Retrieves or creates a shared state wrapper object for a given key in the Obsidian app. * * @param app - The Obsidian app instance. * @param key - The key to store or retrieve the shared state. * @param defaultValue - The default value to use if the shared state does not exist. * @returns The ValueWrapper object that stores the shared state. */ export declare function getObsidianDevUtilsState<T>(app: App | null, key: string, defaultValue: T): ValueWrapper<T>;