@etsoo/react
Version:
TypeScript ReactJs UI Independent Framework
57 lines (56 loc) • 1.3 kB
TypeScript
import { IAction, IUser, IUserData } from "@etsoo/appscript";
import { IProviderProps, IUpdate } from "./IState";
/**
* User action type
* Style like 'const enum' will remove definition of the enum and cause module errors
*/
export declare enum UserActionType {
Login = "LOGIN",
Logout = "LOGOUT",
Update = "UPDATE",
Unauthorized = "UNAUTHORIZED"
}
/**
* User action to manage the user
*/
export interface UserAction<D extends IUser> extends IAction {
/**
* Action type
*/
type: UserActionType;
/**
* User data
*/
user?: IUserData;
/**
* User update callback
*/
update?: (state: D) => void;
}
/**
* User provider props
*/
export type UserProviderProps<D extends IUser> = IProviderProps<UserAction<D>>;
/**
* Users calls with the state
*/
export interface UserCalls<D extends IUser> extends IUpdate<D, UserAction<D>> {
}
/**
* User state
*/
export declare class UserState<D extends IUser> {
/**
* Context
*/
readonly context: import("react").Context<UserCalls<D>>;
/**
* Provider
*/
readonly provider: import("react").FunctionComponent<import("react").PropsWithChildren<UserProviderProps<D>>>;
/**
* Constructor
*/
constructor();
private getChangedFields;
}