import { Observable, Subscription } from "rxjs/Rx"; import { Scheduler } from "rxjs/Scheduler"; import { PropertyChangedEventArgs } from "./events/property-changed-event-args"; import { ReactiveCommand } from "./reactive-command"; /** * Defines a class that represents a reactive object. * This is the base class for View Model classes, and it implements an event system that * allows notification of property changes, which is the basis of the observable pipeline. */ export declare class ReactiveObject { private _propertyChanged; /** * The property that stores all of the data stored in this object. */ private __data; /** * Creates a new reactive object. */ constructor(obj?: Object | Array); private setupProperty(name, val); /** * Gets the observable that represents the stream of "propertyChanged" events from this object. */ readonly propertyChanged: Observable>; protected createPropertyChangedEventArgs(propertyName: string, value: any): PropertyChangedEventArgs; /** * Emits a new property changed event for the given property from this object. */ protected emitPropertyChanged(propertyName: string, newPropertyValue?: any): void; /** * Emits a new property changed event for the given property if it has changed from the previous value. */ protected emitIfPropertyChanged(propertyName: string, oldPropertyValue: any): void; /** * Records the given property before and after the given function is run and raises a property changed notification * if the property value changed. */ protected trackPropertyChanges(prop: string, callback: () => T): T; private static getSingleProperty(obj, property); private static getReactiveProperty(obj, property); private static getDeepProperty(obj, evaluated); private static get(obj, property); /** * Gets the value of the given property from this object. * @param property The name of the property whose value should be retrieved. */ get(property: string | ((vm: this) => T)): T | any; private static setSingleProperty(obj, property, value); private static setReactiveProperty(obj, property, value); private static setDeepProperty(obj, evaluated, value); private static traverse(obj, property, setSingle, setDeep); private static set(obj, property, value); /** * Sets the value of the given property on this object and emits the "propertyChanged" event. * @param property The name of the property to change. * @param value The value to give the property. */ set(property: string | ((vm: this) => T), value: T): void; /** * Builds a proxy object that adds accessed property names to the given array if proxies are supported. * Returns null if proxies are not supported. */ private static buildGhostObject(arr); /** * Runs the given function against a dummy version of the given object. * object that builds a string that represents the properties that should be watched. * @param expr The function that represents the lambda expression. */ private static evaluateLambdaExpression(obj, expr); private static evaluateLambdaErrors(path, expr, currentObj?); private static evaluateLambdaOrString(obj, expression); private static whenSingleProp(obj, prop, emitCurrentVal?); private static whenSingle(obj, expression, emitCurrentVal?); /** * Gets an observable that resolves with the related property changed event whenever the given property updates. */ whenSingle(expression: string | ((o: this) => any), emitCurrentVal?: boolean): Observable>; /** * Gets an observable that resolves with the related property changed event whenever the given property updates. * @param first The name of the first property to watch. */ whenAny(first: string | ((o: this) => T1)): Observable>; /** * Gets an observable that resolves with the related property changed event whenever the given property updates. * @param first The name of the first property to watch. * @param map A function that, given the event arguments for the property, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), map: (_1: PropertyChangedEventArgs) => TResult): Observable; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. */ whenAny(first: string | ((o: this) => T1), second: string): Observable[]>; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. * @param map A function that, given the event arguments for the properties, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), map: (_1: PropertyChangedEventArgs, _2: PropertyChangedEventArgs) => TResult): Observable; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string): Observable[]>; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. * @param map A function that, given the event arguments for the properties, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), map: (_1: PropertyChangedEventArgs, _2: PropertyChangedEventArgs, _3: PropertyChangedEventArgs) => TResult): Observable; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. * @param map A function that, given the event arguments for the properties, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string): Observable[]>; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. * @param map A function that, given the event arguments for the properties, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), map: (_1: PropertyChangedEventArgs, _2: PropertyChangedEventArgs, _3: PropertyChangedEventArgs, _4: PropertyChangedEventArgs) => TResult): Observable>; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. * @param map A function that, given the event arguments for the properties, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), fifth: string | ((o: this) => T5), map: (_1: PropertyChangedEventArgs, _2: PropertyChangedEventArgs, _3: PropertyChangedEventArgs, _4: PropertyChangedEventArgs, _5: PropertyChangedEventArgs) => TResult): Observable>; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. * @param map A function that, given the event arguments for the properties, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), fifth: string | ((o: this) => T5), sixth: string | ((o: this) => T6), map: (_1: PropertyChangedEventArgs, _2: PropertyChangedEventArgs, _3: PropertyChangedEventArgs, _4: PropertyChangedEventArgs, _5: PropertyChangedEventArgs, _6: PropertyChangedEventArgs) => TResult): Observable>; /** * Gets an observable that resolves with the related property changed event whenever the given properties update. * @param properties The names of the properties. * @param map A function that, given the event arguments for the properties, maps to the desired return values. */ whenAny(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), fifth: string | ((o: this) => T5), sixth: string | ((o: this) => T6), seventh: string | ((o: this) => T7), map: (_1: PropertyChangedEventArgs, _2: PropertyChangedEventArgs, _3: PropertyChangedEventArgs, _4: PropertyChangedEventArgs, _5: PropertyChangedEventArgs, _6: PropertyChangedEventArgs, _7: PropertyChangedEventArgs) => TResult): Observable>; private getMapFunction(values); /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. */ whenAnyValue(first: string | ((o: this) => T1)): Observable; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), map: (_1: T1) => TResult): Observable; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @param map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string): Observable<(T1 | T2)[]>; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @param map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), map: (_1: T1, _2: T2) => TResult): Observable; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string): Observable<(T1 | T2 | T3)[]>; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), map: (_1: T1, _2: T2, _3: T3) => TResult): Observable; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string): Observable<(T1 | T2 | T3 | T4)[]>; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), map: (_1: T1, _2: T2, _3: T3, _4: T4) => TResult): Observable; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), fifth: string | ((o: this) => T5), map: (_1: T1, _2: T2, _3: T3, _4: T4, _5: T5) => TResult): Observable; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), fifth: string | ((o: this) => T5), sixth: string | ((o: this) => T6), map: (_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6) => TResult): Observable; /** * Gets an observable that resolves with the related property value(s) whenever the given properties update. * @map A function that, given the values for the properties, maps to the desired return value. */ whenAnyValue(first: string | ((o: this) => T1), second: string | ((o: this) => T2), third: string | ((o: this) => T3), fourth: string | ((o: this) => T4), fifth: string | ((o: this) => T5), sixth: string | ((o: this) => T6), seventh: string | ((o: this) => T7), map: (_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7) => TResult): Observable; private mergeChanges(...changes); /** * Binds the specified property on this object to the specified property on the given other object. * @param view The view whose property should be bound to one of this object's properties. * @param viewModelProp A function that maps this object to the property that should be bound to the view. Alternatively, a string can be used to point out the property. * @param viewProp A function that maps the view to the property that should be bound to this object. Alternatively, a string can be used. * @param scheduler The scheduler that changes to the properties should be observed on. */ bind(view: TView, viewModelProp: (((o: this) => TViewModelProp) | string), viewProp: (((o: TView) => TViewProp) | string), scheduler?: Scheduler): Subscription; /** * Propagates values from the specified property on this object to the specified property on the given view object. * @param view The object that should be bound to this object. * @param viewModelProp The property on this object that should set to the other property. * @param viewProp The property on the view object that should recieve values from the other property. * @return Subscription */ oneWayBind(view: TView, viewModelProp: (((o: this) => TViewModelProp) | string), viewProp: (((o: TView) => TViewProp) | string), scheduler?: Scheduler): Subscription; /** * Binds values recieved from the given observable to the specified property on the given object. * @param observable The Observable object whose values should be piped to the specified property. * @param view The object that the values should be piped to. * @param viewProp The property on the object that the values should be piped to. */ static bindObservable(observable: Observable, view: TView, viewProp: (((o: TView) => TViewProp) | string), scheduler?: Scheduler): Subscription; when(observable: string | Observable): Observable; /** * Attempts to invoke the given command when the given Observable resolves with a new value. * The command will not be invoked unless it can execute. * Returns a cold Observable that resolves with the results of the executions. * The returned Observable MUST be subscribed to in order for the command to execute. * * @param observable The Observable object that should be used as the trigger for the command. * Additionally, if a property name is passed in, the most recent Observable stored at that property is used. * @param command The ReactiveCommand object that should be executed. * If a property name is passed in, the most recent command stored at that property is used. */ invokeCommandWhen(observable: string | Observable, command: string | ReactiveCommand): Observable; /** * Creates a one way binding between the given observable and the specified property on this object. * @param observable The observable that should be bound to the property. * @param property The property that should assume the most recently observed value from the observable. * @param scheduler The scheduler that should be used to observe values from the given observable. */ toProperty(observable: Observable, property: (((o: this) => TProp) | string), scheduler?: Scheduler): Subscription; /** * Returns the data that should be used to convert this reactive object into a JSON string. */ toJSON(): any; /** * Returns the string representation of this reactive object. */ toString(): string; /** * Gets the list of enumerable property names that have been set on the given object. * @param obj The object whose enumerable property names should be returned. */ static keys(obj: Object): string[]; private static clone(obj); }