bindable-decor

0.1.6 • Public • Published
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) ->
            [firstNamelastName].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
  

Readme

Keywords

none

Package Sidebar

Install

npm i bindable-decor

Weekly Downloads

2

Version

0.1.6

License

BSD

Last publish

Collaborators

  • architectd
  • crcn