UNPKG

@omnia/fx-models

Version:
40 lines (39 loc) 1.71 kB
import { GuidValue } from './Guid'; import { IMessageBusTopicSubscription } from './Messaging'; export interface NamedPropertyIdentifier { serviceId: string; name: string; } export interface NamedProperty<T> extends NamedPropertyIdentifier { value: T; } export interface TypedNamedProperty<T> extends NamedPropertyIdentifier { } export interface INamedPropertiesOperations { /** * Gets a property or null if not found * */ getProperty: <T>(typedPropertyDefinition: TypedNamedProperty<T>) => T; } export declare type NamedPropertyCollection = Array<NamedProperty<string>>; export interface IOmniaPropertyBag<T extends OmniaNamedModel> { /** * Get a model from current values, i.e. assumes that the propertybag has been either initialized by calling getAllValues or initialized with values * Returns an instance of the the model with model values populated or null if not found (or if no values have been loaded for this bag) * */ getModel: <Model extends T>(model: new () => Model) => Model; addOrUpdate: (...args: Array<T>) => Promise<Array<T>>; getAllValues: (forceGetFromServer?: boolean) => Promise<Array<T>>; removeValues: (...args: Array<T>) => Promise<void>; removeAllValues: () => Promise<void>; removeOmniaServiceValues: (omniaServiceId: GuidValue) => Promise<void>; onChanged: () => IMessageBusTopicSubscription<void>; } /** * This is the new base for omnia named typed properties * */ export declare abstract class OmniaNamedModel { readonly omniaServiceId: GuidValue; readonly uniqueModelName: string; constructor(omniaServiceId: GuidValue, uniqueModelName: string); }