import type { ValidationTriggerSelector } from './ValidationTriggerSelector'; import type { INotifyCollectionChanged, INotifyCollectionReordered, INotifySetChanged, INotifyMapChanged } from '../../collections'; import type { INotifyPropertiesChanged } from '../../viewModels'; import { type IEvent } from '../../events'; /** * Represent a set of well-known validation triggers. These are used to simplify * object validator configurations as a view model or observable collection can * be directly passed as a trigger. * * @template TKey The type of keys the map contains. * @template TItem The type of items the collection, set, or map contains. * * @see {@link Form.validation} * @see {@link IObjectValidator} * @see {@link ValidationTrigger} */ export type WellKnownValidationTrigger = INotifyPropertiesChanged | INotifyCollectionChanged | INotifyCollectionReordered | INotifySetChanged | INotifyMapChanged | [ INotifyMapChanged & Iterable<[TKey, TItem]>, ValidationTriggerSelector ] | [ (INotifyCollectionChanged | INotifySetChanged) & Iterable, ValidationTriggerSelector ]; /** * Represents a validation trigger. Generally, they wrap an observable object and whenever * it changes the {@linkcode validationTriggered} event is raised. * * @template TTrigger The concrete type that may trigger validations. */ export declare abstract class ValidationTrigger { private readonly _validationTriggeredEventDispatcher; /** * Initializes a new instance of the {@linkcode ValidationTrigger} class. * @param trigger The source object that triggers validation. */ protected constructor(trigger: TTrigger); /** * Gets the source object that triggers validation. */ readonly trigger: TTrigger; /** * Gets an event that is raised whenever the source object triggers a validation. */ readonly validationTriggered: IEvent; /** * A plug-in method that handles the actual event subscription to the {@linkcode trigger}. */ protected abstract subscribeToTarget(): void; /** * A plug-in method that handles the actual event unsubscription to the {@linkcode trigger}. */ protected abstract unsubscribeFromTarget(): void; /** * Raises the {@linkcode validationTriggered} event, notifying that a validation should occur. */ protected notifyValidationTriggered(): void; }