@types/use-global-hook
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

Installation

npm install --save @types/use-global-hook

Summary

This package contains type definitions for use-global-hook (https://github.com/andregardi/use-global-hook#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/use-global-hook.

index.d.ts

import Immer from "immer";

// to ignore strict-export-declare-modifiers error
export {};

// Where S is typeof state and A is typeof associated actions
export interface Store<S, A> {
    state: S;
    actions: A;
    setState(state: S, afterUpdateCallback?: () => void): void;
}

type IProduce = typeof Immer;
export type InitializerFunction<S, A> = (store: Store<S, A>) => void;

export interface Options<S, A> {
    Immer?: IProduce | undefined;
    initializer?: InitializerFunction<S, A> | undefined;
}

type UseGlobal<S, A> =
    & (() => [S, A])
    & (<NS>(stateFunc: (state: S) => NS) => [NS, A])
    & (<NS, NA>(stateFunc: (state: S) => NS, actionsFunc: (state: A) => NA) => [NS, NA])
    & (<NA>(stateFunc: undefined, actionsFunc: (state: A) => NA) => [S, NA]);

// The option property also has an initializer function type for backward compatibility with 0.1.2
// see https://github.com/andregardi/use-global-hook/pull/51/files#diff-5330e30faa98f2945d75901849861a10R4
export default function useStore<S, A>(
    inititalState: S,
    actions: object,
    options?: Options<S, A> | InitializerFunction<S, A>,
): UseGlobal<S, A>;

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: immer

Credits

These definitions were written by James Hong, and Jeremy Powers.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/use-global-hook

Weekly Downloads

1,141

Version

0.3.3

License

MIT

Unpacked Size

5.13 kB

Total Files

5

Last publish

Collaborators

  • types