Skip to content

Typescript #11

@litinskii

Description

@litinskii
declare module 'react-native-user-defaults' {
  interface UserDefaults {
    /**
     * Set information for a key.
     * @param key The key to store the value under.
     * @param value The value to store. It can be a string, number, boolean, object, or array.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or success data.
     * @returns A promise that resolves with the success data.
     */
    set(
      key: string,
      value: string | number | boolean | object | any[],
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;

    /**
     * Get information for a key.
     * @param key The key whose value you want to retrieve.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or the retrieved data.
     * @returns A promise that resolves with the retrieved data.
     */
    get(
      key: string,
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;

    /**
     * Remove an item by key.
     * @param key The key of the item to remove.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or success data.
     * @returns A promise that resolves with the success data.
     */
    remove(
      key: string,
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;

    /**
     * Empty all non-default items.
     * APP default settings will be reserved.
     * @param suiteName Optional. The suite name (group identifier) for shared user defaults.
     * @param cb Optional. A callback function that receives an error or success data.
     * @returns A promise that resolves with the success data.
     */
    empty(
      suiteName?: string,
      cb?: (err: Error | null, data: any) => void,
    ): Promise<any>;
  }

  const userDefaults: UserDefaults;
  export default userDefaults;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions