Models

AJAX Abstraction for a Single Resource

History

The interface for Models is heavily inspired by Backbone, and largely mirrors the implementation of Backbone.Model.

Unlike Backbone's intended usage however, this library should not be used to pass data through your application. It is intended to be used solely as an abstraction tier to simplify AJAX requests.

This means when using it, the expectation is that you configure your Model, instantiate it with data, make the appropriate request, and then serialize the model back into JSON data before using it in your application.

The major differences between Backbone.Model and this version of Model are:

  • All event emitters have been removed. This is purely an abstraction tier, not a way to store your data, or detect when that data has changed.
  • The jQuery.ajax method has been replaced with axios for managing AJAX calls, which also facilitates testing in a non-browser environment (i.e. Node).