propertyDefaults
Specify default behaviors for properties.
static propertyDefaults = PROPDEFINITION
Specify default values using a DefinitionObject object.
import { ObservableObject } from "can/everything";
class RouteData extends ObservableObject {
static propertyDefaults = {
type: String,
enumerable: false
};
}
let rd = new RouteData({ foo: 'bar' });
// `foo` will not be listed as an enumerated property
for(let prop in rd) {
console.log(prop);
}
The above specifies a RouteData type whose properties default to a strictly typed String
and are non-enumerable.
static propertyDefaults = PROPERTY
propertyDefaults can be specified using any of the methods specified by the property type.
import { ObservableObject } from "can/everything";
class Person extends ObservableObject {
static propertyDefaults = String;
}
The above specifies all properties to default to being a strictly defined String
. See Property for other possible values.