ayanami
Version:
A better way to react with state
8 lines (7 loc) • 557 B
TypeScript
import { Ayanami, ConstructorOf, ScopeConfig } from '../core';
import { UseAyanamiInstanceResult as Result } from './use-ayanami-instance';
interface Config<S, U> extends Partial<ScopeConfig> {
selector?: (state: S) => U;
}
export declare function useAyanami<M extends Ayanami<S>, S, U = M extends Ayanami<infer SS> ? SS : never>(A: ConstructorOf<M>, config?: M extends Ayanami<infer S> ? Config<S, U> : never): M extends Ayanami<infer S> ? NonNullable<typeof config> extends Config<S, infer SS> ? Result<M, S, SS> : Result<M, S, S> : never;
export {};