Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Latest commit

 

History

History
37 lines (28 loc) · 630 Bytes

options.md

File metadata and controls

37 lines (28 loc) · 630 Bytes

Property options

Property have couple of advantages over an observable like validation, field mapping, support for default values and also are easier to setup.

var App = blocks.Application();

var Article = App.Model({
  author: App.Property({

    field: 'Author',

    defaultValue: 'John Doe',

    // changing:
    // change:
    // add:
    // adding:
    // remove:
    // removing:
  }),

  date: App.Property({
    on: {
      changing: function () {

      }
    }
  }),

  info: App.Property({
    value: function() {
      return this.author() + ' ' + this.date();
    }
  })
});