You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
63 lines
1.3 KiB
declare namespace SocketIO {
|
|
type EventType = NumEventType | NullEventType | SpecialEventType;
|
|
|
|
type NumEventType =
|
|
| "movie"
|
|
| "series"
|
|
| "episode"
|
|
| "episode-wanted"
|
|
| "movie-wanted";
|
|
|
|
type NullEventType =
|
|
| "connect"
|
|
| "connect_error"
|
|
| "disconnect"
|
|
| "episode-blacklist"
|
|
| "episode-history"
|
|
| "movie-blacklist"
|
|
| "movie-history"
|
|
| "badges"
|
|
| "task"
|
|
| "settings"
|
|
| "languages";
|
|
|
|
type SpecialEventType = "message" | "progress";
|
|
|
|
type ActionType = "update" | "delete";
|
|
|
|
type ReducerCreator<E extends EventType, U, D = U> = ValueOf<
|
|
{
|
|
[P in E]: {
|
|
key: P;
|
|
any?: ActionHandler<null>;
|
|
update?: ActionHandler<U>;
|
|
delete?: ActionHandler<D>;
|
|
};
|
|
}
|
|
>;
|
|
|
|
type Event = {
|
|
type: EventType;
|
|
action: ActionType;
|
|
payload: any;
|
|
};
|
|
|
|
type ActionHandler<T> = T extends null ? () => void : (payload: T[]) => void;
|
|
|
|
type Reducer =
|
|
| ReducerCreator<NumEventType, number>
|
|
| ReducerCreator<NullEventType, null>
|
|
| ReducerCreator<"message", string>
|
|
| ReducerCreator<"progress", CustomEvent.Progress, string>;
|
|
|
|
type ActionRecord = {
|
|
[P in EventType]?: {
|
|
[R in ActionType]?: any[];
|
|
};
|
|
};
|
|
|
|
namespace CustomEvent {
|
|
type Progress = Server.Progress;
|
|
}
|
|
}
|