Skip to content

Commit 2207bdf

Browse files
committed
Added the BindablePropertyConfig interface
* describes the configuration object that can be passed to customize the bindable decorator and the BindableProperty class * used the interface type appropriate * fixed a few minor typos (spelling) * built and ran tests (+1 squashed commits)
1 parent 64e73f5 commit 2207bdf

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

src/bindable-property.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ function getObserver(instance, name) {
3333
export class BindableProperty {
3434
/**
3535
* Creates an instance of BindableProperty.
36-
* @param nameOrConfig The name of the property or a cofiguration object.
36+
* @param nameOrConfig The name of the property or a configuration object.
3737
*/
38-
constructor(nameOrConfig: string | Object) {
38+
constructor(nameOrConfig: string | BindablePropertyConfig) {
3939
if (typeof nameOrConfig === 'string') {
4040
this.name = nameOrConfig;
4141
} else {
@@ -219,11 +219,11 @@ export class BindableProperty {
219219
}
220220

221221
observer = observerLookup[name] = new BehaviorPropertyObserver(
222-
this.owner.taskQueue,
223-
viewModel,
224-
name,
225-
selfSubscriber
226-
);
222+
this.owner.taskQueue,
223+
viewModel,
224+
name,
225+
selfSubscriber
226+
);
227227

228228
Object.defineProperty(viewModel, name, {
229229
configurable: true,

src/decorators.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function customElement(name: string): any {
5858
* @param defaultBindingMode The default binding mode to use when the attribute is bound with .bind.
5959
* @param aliases The array of aliases to associate to the custom attribute.
6060
*/
61-
export function customAttribute(name: string, defaultBindingMode?: number, aliases?: string[]): any {
61+
export function customAttribute(name: string, defaultBindingMode?: bindingMode, aliases?: string[]): any {
6262
return function(target) {
6363
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, target);
6464
r.attributeName = validateBehaviorName(name, 'custom attribute');
@@ -85,7 +85,7 @@ export function templateController(target?): any {
8585
* Decorator: Specifies that a property is bindable through HTML.
8686
* @param nameOrConfigOrTarget The name of the property, or a configuration object.
8787
*/
88-
export function bindable(nameOrConfigOrTarget?: string | Object, key?, descriptor?): any {
88+
export function bindable(nameOrConfigOrTarget?: string | BindablePropertyConfig, key?, descriptor?): any {
8989
let deco = function(target, key2, descriptor2) {
9090
let actualTarget = key2 ? target.constructor : target; //is it on a property or a class?
9191
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, actualTarget);
@@ -224,14 +224,14 @@ export function useView(path: string): any {
224224
* @param dependencies A list of dependencies that the template has.
225225
* @param dependencyBaseUrl A base url from which the dependencies will be loaded.
226226
*/
227-
export function inlineView(markup:string, dependencies?:Array<string|Function|Object>, dependencyBaseUrl?:string): any {
227+
export function inlineView(markup: string, dependencies?: Array<string | Function | Object>, dependencyBaseUrl?: string): any {
228228
return useViewStrategy(new InlineViewStrategy(markup, dependencies, dependencyBaseUrl));
229229
}
230230

231231
/**
232232
* Decorator: Indicates that the component has no view.
233233
*/
234-
export function noView(targetOrDependencies?:Function|Array<any>, dependencyBaseUrl?:string): any {
234+
export function noView(targetOrDependencies?: Function | Array<any>, dependencyBaseUrl?: string): any {
235235
let target;
236236
let dependencies;
237237
if (typeof targetOrDependencies === 'function') {

src/interfaces.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {bindingMode} from 'aurelia-binding';
12
import {View} from './view';
23
import {ViewStrategy} from './view-strategy';
34

@@ -67,3 +68,21 @@ interface DynamicComponentGetViewStrategy {
6768
*/
6869
getViewStrategy(): string|ViewStrategy;
6970
}
71+
72+
/**
73+
* An optional interface describing the configuration object that can be specified to customize bindable properties.
74+
*/
75+
interface BindablePropertyConfig {
76+
/**
77+
* The default binding mode of the property.
78+
*/
79+
defaultBindingMode?: bindingMode;
80+
/**
81+
* The name of a view model method to invoke when the property is updated.
82+
*/
83+
changeHandler?: string;
84+
/**
85+
* The name of the property.
86+
*/
87+
name?: string;
88+
}

0 commit comments

Comments
 (0)