Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bindable-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function getObserver(instance, name) {
export class BindableProperty {
/**
* Creates an instance of BindableProperty.
* @param nameOrConfig The name of the property or a cofiguration object.
* @param nameOrConfig The name of the property or a configuration object.
*/
constructor(nameOrConfig: string | Object) {
constructor(nameOrConfig: string | BindablePropertyConfig) {
if (typeof nameOrConfig === 'string') {
this.name = nameOrConfig;
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function customElement(name: string): any {
* @param defaultBindingMode The default binding mode to use when the attribute is bound with .bind.
* @param aliases The array of aliases to associate to the custom attribute.
*/
export function customAttribute(name: string, defaultBindingMode?: number, aliases?: string[]): any {
export function customAttribute(name: string, defaultBindingMode?: bindingMode, aliases?: string[]): any {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bindingMode is unfortunately a const object at this time. So, I don't think it can be used as a type. Can we revert this back to number?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that with newest API on BindableProperty, it now understands lookup property of bindingMode such as toView, fromView, twoView, oneTime

@EisenbergEffect do we need to adjust this based on that ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bigopon So, it will accept either a string or a number?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EisenbergEffect Yes it's added in this commit e7da973#diff-8fecf3f03eea2e940742fe22c0791bfbR51

It was to support Aurelia plugins / classes

return function(target) {
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, target);
r.attributeName = validateBehaviorName(name, 'custom attribute');
Expand All @@ -85,7 +85,7 @@ export function templateController(target?): any {
* Decorator: Specifies that a property is bindable through HTML.
* @param nameOrConfigOrTarget The name of the property, or a configuration object.
*/
export function bindable(nameOrConfigOrTarget?: string | Object, key?, descriptor?): any {
export function bindable(nameOrConfigOrTarget?: string | BindablePropertyConfig, key?, descriptor?): any {
let deco = function(target, key2, descriptor2) {
let actualTarget = key2 ? target.constructor : target; //is it on a property or a class?
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, actualTarget);
Expand Down Expand Up @@ -224,14 +224,14 @@ export function useView(path: string): any {
* @param dependencies A list of dependencies that the template has.
* @param dependencyBaseUrl A base url from which the dependencies will be loaded.
*/
export function inlineView(markup:string, dependencies?:Array<string|Function|Object>, dependencyBaseUrl?:string): any {
export function inlineView(markup: string, dependencies?: Array<string | Function | Object>, dependencyBaseUrl?: string): any {
return useViewStrategy(new InlineViewStrategy(markup, dependencies, dependencyBaseUrl));
}

/**
* Decorator: Indicates that the component has no view.
*/
export function noView(targetOrDependencies?:Function|Array<any>, dependencyBaseUrl?:string): any {
export function noView(targetOrDependencies?: Function | Array<any>, dependencyBaseUrl?: string): any {
let target;
let dependencies;
if (typeof targetOrDependencies === 'function') {
Expand Down
27 changes: 27 additions & 0 deletions src/interfaces.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {bindingMode} from 'aurelia-binding';
import {View} from './view';
import {ViewStrategy} from './view-strategy';

Expand Down Expand Up @@ -67,3 +68,29 @@ interface DynamicComponentGetViewStrategy {
*/
getViewStrategy(): string|ViewStrategy;
}

/**
* An optional interface describing the configuration object that can be specified to customize bindable properties.
*/
interface BindablePropertyConfig {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also takes a property name defaultValue, type any

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

/**
* The default binding mode of the property.
*/
defaultBindingMode?: bindingMode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will need to be number, since bindingMode is actually an object, not an enum or union type.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that simple.
From usage it should be union type.
But I can't see how to make it possible

/**
* The name of a view model method to invoke when the property is updated.
*/
changeHandler?: string;
/**
* Designates the property as the default bindable property among all the other bindable properties when used in a custom attribute with multiple bindable properties.
*/
primaryProperty?: boolean;
/**
* The name of the property.
*/
name?: string;
/**
* A default value for the property.
*/
defaultValue?: any
}