本文整理匯總了TypeScript中aurelia-framework.ObserverLocator.getObserver方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ObserverLocator.getObserver方法的具體用法?TypeScript ObserverLocator.getObserver怎麽用?TypeScript ObserverLocator.getObserver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類aurelia-framework.ObserverLocator
的用法示例。
在下文中一共展示了ObserverLocator.getObserver方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: valueChanged
public valueChanged(newValue: Command, oldValue: Command): void {
this.command = newValue;
if (oldValue) {
this.observerLocator
.getObserver(oldValue, "isExecuting")
.unsubscribe(this.onCommandIsExecutingChanged.bind(this));
this.observerLocator
.getObserver(oldValue, "canExecute")
.unsubscribe(this.onCommandCanExecuteChanged.bind(this));
}
if (newValue) {
this.observerLocator
.getObserver(newValue, "isExecuting")
.subscribe(this.onCommandIsExecutingChanged.bind(this));
this.observerLocator
.getObserver(newValue, "canExecute")
.subscribe(this.onCommandCanExecuteChanged.bind(this));
this.onCommandIsExecutingChanged(this.command.isExecuting, undefined);
this.onCommandCanExecuteChanged(this.command.canExecute, undefined);
}
}
示例2: commandChanged
public commandChanged(newValue: Command, oldValue: Command) {
if (oldValue) {
this.observerLocator
.getObserver(oldValue, "error")
.unsubscribe(this.onCommandErrorChanged.bind(this));
}
if (newValue) {
this.observerLocator
.getObserver(newValue, "error")
.subscribe(this.onCommandErrorChanged.bind(this));
}
}
示例3: observeProperties
observeProperties(properties, callback:IChangedPropertyCallback) {//:string[]|any
var subscriptions = [], object, internalCallback = (propertyName, source) => {
return (newValue, oldValue) => {
callback(propertyName, newValue, oldValue, source);
}
};
for(var propertyName in properties) {
object = properties[propertyName];
subscriptions.push(
this.observerLocator
.getObserver(object, propertyName)
.subscribe(internalCallback(propertyName, object)));
}
// return dispose function
return () => {
while(subscriptions.length) {
subscriptions.pop()();
}
}
}