UNPKG

@peterwidmer/form-store

Version:

reactive store for dynamics 365 forms

27 lines (25 loc) 1.46 kB
/// <reference types="xrm" /> interface PropertyContext { previousValue: any; changedProperty: string; } type SetValueTypeFn<E> = <Key extends string & keyof E>(property: Key, value: E[Key]) => void; type GetValueTypeFn<E> = <Key extends string & keyof E>(property: Key) => E[Key]; type RegisterTypeFn<E> = <Key extends string & keyof E>(fn: (callback: any, propertyContext?: PropertyContext) => void, crmField: Key[], otherProperties?: Key[]) => void; type UnsubscribeTypeFn<E> = <Key extends string & keyof E>(event: Key, fn: (message: E[Key]) => void) => void; type GetEventContextTypeFn = () => Xrm.Events.EventContext; type GetFormContextTypeFn = () => Xrm.FormContext; type GetContextEntityNameFn = () => string; type CompleteRegistrationFn = () => void; type Store<E> = { setValue: SetValueTypeFn<E>; getValue: GetValueTypeFn<E>; unsubscribe: UnsubscribeTypeFn<E>; register: RegisterTypeFn<E>; getEventContext: GetEventContextTypeFn; getFormContext: GetFormContextTypeFn; getContextEntityName: GetContextEntityNameFn; completeRegistration: CompleteRegistrationFn; }; declare function CreateStore<E>(eventContext: Xrm.Events.EventContext): Store<E>; export { type CompleteRegistrationFn, CreateStore, type GetContextEntityNameFn, type GetEventContextTypeFn, type GetFormContextTypeFn, type GetValueTypeFn, type PropertyContext, type RegisterTypeFn, type SetValueTypeFn, type Store, type UnsubscribeTypeFn };