UNPKG

anux-common

Version:

[![Build Status](https://travis-ci.com/Anupheaus/anux-common.svg?branch=master)](https://travis-ci.com/Anupheaus/anux-common) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/dd0e0bd3a96247a5a78c02a812f949f8)](https://www.codacy.com/app/Anuphea

17 lines (16 loc) 1.38 kB
export declare type Unsubscribe = () => void; declare type AnonymousEvent = (...args: any[]) => any; declare type EventDelegate<FuncType extends AnonymousEvent = AnonymousEvent> = (delegate: FuncType) => Unsubscribe; declare type GetArgsFromEvent<EventType> = EventType extends EventDelegate<(...args: infer A) => any> ? A : never; declare type GetReturnValueFromEvent<EventType> = EventType extends EventDelegate<(...args: any[]) => infer A> ? (A extends Promise<infer B> ? Promise<B[]> : A[]) : never; export declare const Event: { create<FuncType extends AnonymousEvent>(): EventDelegate<FuncType>; raise<EventType extends EventDelegate<AnonymousEvent>>(event: EventType, ...args: GetArgsFromEvent<EventType>): GetReturnValueFromEvent<EventType>; enable<EventType_1 extends EventDelegate<AnonymousEvent>>(event: EventType_1): void; disable<EventType_2 extends EventDelegate<AnonymousEvent>>(event: EventType_2): void; setEnabled<EventType_3 extends EventDelegate<AnonymousEvent>>(event: EventType_3, isEnabled: boolean): void; getSubscriptionCountFor<EventType_4 extends EventDelegate<AnonymousEvent>>(event: EventType_4): number; isEnabled<EventType_5 extends EventDelegate<AnonymousEvent>>(event: EventType_5): boolean; dispose<EventType_6 extends EventDelegate<AnonymousEvent>>(...events: EventType_6[]): void; }; export {};