UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

27 lines 1.6 kB
import type { CallbackPriority } from "isaac-typescript-definitions"; import type { ModCallbackCustom } from "../../enums/ModCallbackCustom"; import type { AddCallbackParametersCustom } from "../../interfaces/private/AddCallbackParametersCustom"; import type { AllButFirst } from "../../types/AllButFirst"; import { Feature } from "./Feature"; export type FireArgs<T extends ModCallbackCustom> = Parameters<AddCallbackParametersCustom[T][0]>; export type OptionalArgs<T extends ModCallbackCustom> = AllButFirst<AddCallbackParametersCustom[T]>; /** * The base class for a custom callback. Individual custom callbacks (and validation callbacks) will * extend from this class. */ export declare abstract class CustomCallback<T extends ModCallbackCustom> extends Feature { private subscriptions; addSubscriber(priority: CallbackPriority | int, callbackFunc: AddCallbackParametersCustom[T][0], ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): void; /** * If the submitted function does not match any of the existing subscriptions, this method will do * nothing. */ removeSubscriber(callback: AddCallbackParametersCustom[T][0]): void; fire: (...fireArgs: FireArgs<T>) => ReturnType<AddCallbackParametersCustom[T][0]>; /** * This method needs to be overwritten for any callback that has optional filtration arguments. * See "shouldFire.ts" for methods tailored to specific kinds of callbacks. */ protected shouldFire: (fireArgs: FireArgs<T>, optionalArgs: OptionalArgs<T>) => boolean; } //# sourceMappingURL=CustomCallback.d.ts.map