UNPKG

rehance-forms

Version:
27 lines (26 loc) 723 B
import { BaseContext } from "./ScopeContext"; export declare type EventBusSubscriber = (ev: FormEvent) => void; export declare enum FormEventSignal { SubmitForm = 0, ScopeUpdate = 1, FieldCreated = 2, FieldUpdate = 3, FieldDestroyed = 4 } export declare type FormEvent = { signal: FormEventSignal; scope: BaseContext; field?: string; }; export declare class EventBus { private _id; /** * Trigger the bus using the given event context. */ trigger: (ev: FormEvent) => void; /** * Add a subscriber to the event bus, the returned function will automatically remove * the given subscriber. */ listen: (subscriber: EventBusSubscriber) => () => void; }