-
Notifications
You must be signed in to change notification settings - Fork 2
Schemas And Types
Justin Meyer edited this page Sep 16, 2021
·
9 revisions
Map types:
{
type: "map",
keys: {
name: MaybeString
id: MaybeNumber
}
}
List Types
{
type: "list",
values: String
keys: {
count: Number
}
}
{
// BASIC PROPERTIES
// These are used a LOT of places in CanJS.
[can.isMember](value){
return // if `value` is an instance of the type
}
[can.new](value) {
return // make an instance of the type given value
}
[can.serialize](value) {
return // an JSON.stringify() representation of the instance
}
// SET ENHANCEMENTS
// Properties on a type used to help set logic
// This type is used as the class when doing query logic comparisons.
// For example, you might want {date: "10-22"} on your observables to remain very
// string-like but you need CQL to treat that as a date.
[can.SetType]: {
hydrate(valueToHydrate, childrenHydrator) {
return // hydrated value
}
}
}