@types/redux-promise-listener
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

Installation

npm install --save @types/redux-promise-listener

Summary

This package contains type definitions for redux-promise-listener (https://github.com/erikras/redux-promise-listener).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/redux-promise-listener.

index.d.ts

import { AnyAction, Middleware } from "redux";

export default ReduxPromiseListener.createListener;

declare namespace ReduxPromiseListener {
    type ActionMatcher = (action: AnyAction) => boolean;

    interface Config<
        StartAction extends AnyAction,
        ResolveAction extends AnyAction,
        RejectAction extends AnyAction,
        TReturn,
    > {
        start: string;
        resolve: string | ActionMatcher;
        reject: string | ActionMatcher;
        setPayload?: ((action: StartAction, payload: any) => AnyAction) | undefined;
        getPayload?: ((action: ResolveAction) => TReturn) | undefined;
        getError?: ((action: RejectAction) => any) | undefined;
    }

    interface AsyncFunction<TReturn> {
        asyncFunction: (payload?: any) => Promise<TReturn>;
        unsubscribe: () => void;
    }

    interface PromiseListener {
        middleware: Middleware<{}, AnyAction>;
        createAsyncFunction: <
            // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
            StartAction extends AnyAction,
            // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
            ResolveAction extends AnyAction,
            // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
            RejectAction extends AnyAction,
            TReturn = ResolveAction["payload"],
        >(
            config: Config<StartAction, ResolveAction, RejectAction, TReturn>,
        ) => AsyncFunction<TReturn>;
    }

    function createListener(): PromiseListener;
}

Additional Details

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

Credits

These definitions were written by hikiko4ern.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/redux-promise-listener

Weekly Downloads

1,284

Version

1.1.8

License

MIT

Unpacked Size

5.83 kB

Total Files

5

Last publish

Collaborators

  • types