Models

AJAX Abstraction for a Single Resource

Custom Properties

When creating models, you can also define your own custom properties and methods, and use them in other methods, or invoke them directly.

To illustrate, take a look at this code:

import { Model } from 'lore-models';

const Tweet = Model.extend({
  wordCount: function() {
    return this.attributes.text.split(' ').length;
  }
});

const t1 = new Tweet({
  text: 'Some old tweet'
});

In the code above, we can now call tweet.wordCount() and it would return 3.