Skip to content

Instantly share code, notes, and snippets.

@rolaveric
Last active September 8, 2015 10:54
Show Gist options
  • Save rolaveric/3abce7410cb95da93446 to your computer and use it in GitHub Desktop.
Save rolaveric/3abce7410cb95da93446 to your computer and use it in GitHub Desktop.
class MyController {
// ... snip
viewValue(path) {
// getCache() returns a JSON fragment, so we need to parse the path
const value = this.$parse(path)(this.model.getCache(path));
if (typeof value !== 'undefined') {
return typeof value === 'object' ? value.value : value;
}
// Cache miss - request the real value
this.model.getValue(path)
.subscribe(_ => this.$scope.$evalAsync());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment