import { Observable } from 'rxjs'; import type { BreezeEvent } from '../core/event.js'; import type { Entity, PropertyChangedEventArgs } from '../entity/entity-aspect.js'; import type { EntityChangedEventArgs, EntityManager, ValidationErrorsChangedEventArgs } from '../manager/entity-manager.js'; /** * Any {@link BreezeEvent} as an Observable: each value the event publishes is emitted, for as long * as the subscription lasts. * * The other functions in this module are this, applied to a particular event. Use it directly for * the ones they do not cover - `metadataStore.metadataFetched`, say. * * ```ts * fromBreezeEvent(em.metadataStore.metadataFetched).subscribe(args => console.log(args.metadata)); * ``` * * An error thrown by a subscriber does not reach Breeze: rxjs reports it on its own, and the * event's other subscribers still hear about the change. * * @param event - the event to observe * @returns an Observable that subscribes to `event` when it is subscribed to, and unsubscribes when * it is torn down */ export declare function fromBreezeEvent(event: BreezeEvent): Observable; /** * {@link EntityManager.entityChanged} as an Observable: every entity added, attached, detached, * changed, saved or rejected in `em`. * * Filter for what you want with rxjs: * * ```ts * entityChanged$(em).pipe( * filter(e => e.entityAction === EntityAction.PropertyChange), * ).subscribe(e => markDirty(e.entity)); * ``` */ export declare function entityChanged$(em: EntityManager): Observable; /** * Whether `em` has unsaved changes, as an Observable that starts with the current value. * * {@link EntityManager.hasChangesChanged} only fires on a change, so on its own it cannot tell a * late subscriber what the answer is *now*. This emits `em.hasChanges()` as soon as it is * subscribed to, then each change after that, and never the same value twice in a row. Bind a Save * button to it and the button is right from the first render. * * ```ts * hasChanges$(em).subscribe(dirty => saveButton.disabled = !dirty); * ``` * * The current value is read when you subscribe, not when you call this function. */ export declare function hasChanges$(em: EntityManager): Observable; /** * {@link EntityManager.validationErrorsChanged} as an Observable: validation errors added to or * removed from any entity in `em`. * * Each value says what changed, not the complete set. For "every validation error in the manager * right now", see the recipe in the guide, which builds one from this. */ export declare function validationErrorsChanged$(em: EntityManager): Observable; /** * {@link EntityAspect.propertyChanged} as an Observable: each property of one entity that changes. * * ```ts * propertyChanged$(order).pipe( * filter(e => e.propertyName === 'shipCountry'), * ).subscribe(() => recalculateTax(order)); * ``` * * A live subscription keeps `entity` reachable, as any subscription to it would. Unsubscribe when * the screen showing it goes away. */ export declare function propertyChanged$(entity: Entity): Observable;