Skip to content

Commit

Permalink
feat(view-resources): enable arbitrary named value resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed May 25, 2016
1 parent c204647 commit 4f85ecf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/view-resources.js
Expand Up @@ -90,6 +90,7 @@ export class ViewResources {
this.valueConverters = Object.create(null);
this.bindingBehaviors = Object.create(null);
this.attributeMap = Object.create(null);
this.values = Object.create(null);
this.beforeCompile = this.afterCompile = this.beforeCreate = this.afterCreate = this.beforeBind = this.beforeUnbind = false;
}

Expand Down Expand Up @@ -264,4 +265,22 @@ export class ViewResources {
getBindingBehavior(name: string): Object {
return this.bindingBehaviors[name] || (this.hasParent ? this.parent.getBindingBehavior(name) : null);
}

/**
* Registers a value.
* @param name The name of the value.
* @param value The value.
*/
registerValue(name: string, value: any): void {
register(this.values, name, value, 'a value');
}

/**
* Gets a value.
* @param name The name of the value.
* @return The value.
*/
getValue(name: string): any {
return this.values[name] || (this.hasParent ? this.parent.getValue(name) : null);
}
}

0 comments on commit 4f85ecf

Please sign in to comment.