0.1.6 • Published 10 years ago

bindable-decor v0.1.6

Weekly downloads
3
License
BSD
Repository
github
Last release
10 years ago
decor     = require("bindable-decor")
bindable  = require("bindable")
factory   = decor.factory()

factory.use(decor.bindable)
factory.use(decor.preload)
factory.use(decor.virtuals)



class Person extends bindable.Object

  ###
   bindings to properties on this model
  ###
  
  bindings:
    "firstName, lastName": 
      "fullName":
        "map": 
          "to": (firstName, lastName) ->
            [firstName, lastName].join(" ")
            
  ###
   validates the properties on this model
  ###
  
  fields:
    firstName: "string"
    lastName: "string"
    fullName: "string"
  
  ###
   virtual properties only get called when bound to
  ###
  
  virtuals:
    classes: (next) ->
      loadClasses @, next
    
  ###
  ###
  
  constructor: () ->
    super()
    
    
person = new Person({ firstName: "craig", lastName: "condon" })
factory.decorate(person)

# nothing
person.get("classes");

# trigger virtual
person.bind("classes").to (value) ->
  console.log classes
  
0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.7

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.1

11 years ago