import { MapperFactory } from '@tdm/core/tdm'; import { ResourceControl, ResourceControlToken } from '@tdm/data'; /** * * ## Observables and `ActiveRecordState` * `ActiveRecordState` notification mechanism is based on observables. * This is great for UI interfaces but requires implementing tear down logic, that is unsubscribing * from stream. To help with that, all of the streams in `ActiveRecordState` are shared & lazy, they will only * register if accessed to and automatically disconnect when the number of subscribers is 0. * * You can also call `ActiveRecordState.disconnect()` to clear all subscriptions. * * When using an observable aware UI framework subscriptions managed by the framework so as long as * you don't manually subscribe you are safe. e.g: In Angular using the `async` pipe (`|`) will also * unsubscribe when the component get disposed. */ export declare class ResourceControlFlow extends ResourceControl { readonly hasSnapshot: boolean; protected snapshot: any; /** * Reply the last operation. * Busy state must be false and the resource should have been executed at least once (any action) */ replay(): ResourceControl; /** * Reply the last operation after the provided resources finish their current operation. * This method will not invoke a `replay` for the provided resources, they are assumed in-flight or post-flight. * * For the current resource, the same rules that apply on `replay()` apply on `replayAfter`, i.e. the busy state must * be false and the resource should have been executed at least once. * @param resources * @param ignoreError Whether to reply or not if an error is thrown from some or all of the resources. * always: Always execute the reply operation * some: Execute the reply operation if at least one item did not throw. * never: Don't execute the reply operation if at least one item threw. */ replayAfter(resources: ResourceControlToken | ResourceControlToken[], ignoreError?: 'always' | 'some' | 'never'): void; /** * Creates a snapshot of the current instance and stores it. * Only one snapshot is stored per instance, if a new one is created the previous snapshot is overwriten. * This snapshot is created using serialization which means that all `@Model()` and `@Prop()` rules apply. * * @param mapperFactory An optional [[MapperFactory]] to use, defaults to the mapper set for the model or * [[directMapper]] if not set. */ createSnapshot(mapperFactory?: MapperFactory): void; /** * Restores a previously created snapshot into the current instance (merge). * If a snapshot does not exist it will not restore, nothing is thrown. (use hasSnapshot to check) * Snapshot is removed after restoring. * This snapshot is restored using deserialization which means that all `@Model()` and `@Prop()` rules apply. * * @param mapperFactory An optional [[MapperFactory]] to use, defaults to the mapper set for the model or * [[directMapper]] if not set. */ restoreSnapshot(mapperFactory?: MapperFactory): void; /** * Clone's (deep) the resource. * This is a deep clone done using serialization -> deserialization, which means that all `@Model()` and `@Prop()` * rules apply. * * @param mapperFactory An optional [[MapperFactory]] to use, defaults to the mapper set for the model or * [[directMapper]] if not set. */ clone(mapperFactory?: MapperFactory): T; } export declare function init(): void;