Skip to content

Commit

Permalink
Release 0.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
emuvente committed Mar 28, 2016
1 parent 74fb205 commit c8ad7e5
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backbone.siren",
"version": "0.4.2",
"version": "0.4.3",
"dependencies": {
"backbone": "~1.1.0",
"jquery": "~2.0.0",
Expand Down
27 changes: 19 additions & 8 deletions dist/amd/backbone.siren.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Backbone.Siren v0.4.2
* Backbone.Siren v0.4.3
*
* Copyright (c) 2016 Kiva Microfunds
* Licensed under the MIT license.
Expand Down Expand Up @@ -639,8 +639,6 @@ define(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) {


/**
* @todo is this even being used?
*
* Wraps the standard Backbone.ajax()
*
* @param {String} url
Expand Down Expand Up @@ -689,12 +687,12 @@ define(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) {
* @param {Object} options
* @returns {Promise}
*/
, resolve: function (urls, options) {
, resolve: function (urls, options, lastRequestObj) {
if (_.isArray(urls)) {
return BbSiren.resolveMany(urls, options);
}

return BbSiren.resolveOne(urls, options);
return BbSiren.resolveOne(urls, options, lastRequestObj);
}


Expand Down Expand Up @@ -726,9 +724,11 @@ define(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) {
* @param {Object} options
* @param {Object} options.store - store instance @todo remove the need to have this parameter
* @todo - add an options.ajaxOptions parameter.
* @param {Object} lastRequestObj - a reference to an object in which to store a reference to the last request
*/
, resolveOne: function (url, options) {
, resolveOne: function (url, options, lastRequestObj) {
options = options || {};
lastRequestObj = lastRequestObj || {};


// @todo - rootUrl should reflect the options.data object if it is set
Expand Down Expand Up @@ -791,7 +791,7 @@ define(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) {
store.addRequest(options.data ? rootUrl + '?' + $.param(options.data) : rootUrl, deferred.promise());
}

BbSiren.ajax(rootUrl, options)
lastRequestObj.request = BbSiren.ajax(rootUrl, options)
.done(function (rawEntity) {
var bbSiren = BbSiren.parse(rawEntity, options);
deferred.resolve(bbSiren);
Expand Down Expand Up @@ -1205,6 +1205,17 @@ define(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) {
this.options = options;
this.isAbsoluteRegExp = new RegExp('^(?:[a-z]+:)?//', 'i');
this.alternateRoots = mapRoots(options.alternateRoots);
this.lastRequestObj = {};
}


/**
* Aborts the last request if it exists
*/
, abortLastRequest: function() {
if(this.lastRequestObj.request) {
this.lastRequestObj.request.abort();
}
}


Expand Down Expand Up @@ -1259,7 +1270,7 @@ define(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) {
});
}

return BbSiren.resolve(urls, options);
return BbSiren.resolve(urls, options, this.lastRequestObj);
}
};

Expand Down
4 changes: 2 additions & 2 deletions dist/amd/backbone.siren.min.js

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions dist/iife/backbone.siren.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Backbone.Siren v0.4.2
* Backbone.Siren v0.4.3
*
* Copyright (c) 2016 Kiva Microfunds
* Licensed under the MIT license.
Expand Down Expand Up @@ -639,8 +639,6 @@


/**
* @todo is this even being used?
*
* Wraps the standard Backbone.ajax()
*
* @param {String} url
Expand Down Expand Up @@ -689,12 +687,12 @@
* @param {Object} options
* @returns {Promise}
*/
, resolve: function (urls, options) {
, resolve: function (urls, options, lastRequestObj) {
if (_.isArray(urls)) {
return BbSiren.resolveMany(urls, options);
}

return BbSiren.resolveOne(urls, options);
return BbSiren.resolveOne(urls, options, lastRequestObj);
}


Expand Down Expand Up @@ -726,9 +724,11 @@
* @param {Object} options
* @param {Object} options.store - store instance @todo remove the need to have this parameter
* @todo - add an options.ajaxOptions parameter.
* @param {Object} lastRequestObj - a reference to an object in which to store a reference to the last request
*/
, resolveOne: function (url, options) {
, resolveOne: function (url, options, lastRequestObj) {
options = options || {};
lastRequestObj = lastRequestObj || {};


// @todo - rootUrl should reflect the options.data object if it is set
Expand Down Expand Up @@ -791,7 +791,7 @@
store.addRequest(options.data ? rootUrl + '?' + $.param(options.data) : rootUrl, deferred.promise());
}

BbSiren.ajax(rootUrl, options)
lastRequestObj.request = BbSiren.ajax(rootUrl, options)
.done(function (rawEntity) {
var bbSiren = BbSiren.parse(rawEntity, options);
deferred.resolve(bbSiren);
Expand Down Expand Up @@ -1205,6 +1205,17 @@
this.options = options;
this.isAbsoluteRegExp = new RegExp('^(?:[a-z]+:)?//', 'i');
this.alternateRoots = mapRoots(options.alternateRoots);
this.lastRequestObj = {};
}


/**
* Aborts the last request if it exists
*/
, abortLastRequest: function() {
if(this.lastRequestObj.request) {
this.lastRequestObj.request.abort();
}
}


Expand Down Expand Up @@ -1259,7 +1270,7 @@
});
}

return BbSiren.resolve(urls, options);
return BbSiren.resolve(urls, options, this.lastRequestObj);
}
};

Expand Down
4 changes: 2 additions & 2 deletions dist/iife/backbone.siren.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backbone.siren",
"version": "0.4.2",
"version": "0.4.3",
"description": "Converts Siren JSON representations into Backbone Models and Collections",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c8ad7e5

Please sign in to comment.