Last active
April 1, 2016 09:44
-
-
Save Thanood/8e0ece3181508123e1ac to your computer and use it in GitHub Desktop.
observer-locator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ObserverLocator } from 'aurelia-binding'; | |
import { inject } from 'aurelia-dependency-injection'; | |
@inject(ObserverLocator) | |
export class App { | |
constructor(observerLocator) { | |
this.subscription = observerLocator.getObserver(this, 'selectedValue'); | |
this.subscription.subscribe(this.selectedValueChanged); | |
} | |
detached() { | |
this.subscription.unsubscribe(); | |
} | |
selectedValue = ''; | |
selectedValueChanged(newValue) { | |
console.log('select changed', newValue); | |
} | |
setSelectedValue() { | |
this.selectedValue = 'ny2'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Better use the bindingEngine
http://stackoverflow.com/questions/28419242/property-change-subscription-with-aurelia/28437456#28437456