Comparing version 0.0.1 to 0.0.2
@@ -87,11 +87,9 @@ 'use strict'; | ||
this.model = _Model2.default; | ||
this.api = new _Api2.default(this.url()); | ||
this.api = new _Api2.default(this.basePath); | ||
if (data) this.set(data); | ||
} | ||
/* | ||
* Get a resource at a given position | ||
/** | ||
* Returns the URL where the model's resource would be located on the server. | ||
*/ | ||
@@ -101,2 +99,22 @@ | ||
_createClass(Collection, [{ | ||
key: 'url', | ||
value: function url() { | ||
return '/'; | ||
} | ||
/** | ||
* Specifies the model class for that collection | ||
*/ | ||
}, { | ||
key: 'model', | ||
value: function model() { | ||
return _Model2.default; | ||
} | ||
/** | ||
* Get a resource at a given position | ||
*/ | ||
}, { | ||
key: 'at', | ||
@@ -107,3 +125,3 @@ value: function at(index) { | ||
/* | ||
/** | ||
* Get a resource with the given id or uuid | ||
@@ -130,3 +148,3 @@ */ | ||
var Model = this.model; | ||
var Model = this.model(); | ||
@@ -159,3 +177,5 @@ var instances = models.map(function (attr) { | ||
/** | ||
* Set the models into the collection. | ||
* Sets the models into the collection. | ||
* | ||
* You can disable adding, changing or removing. | ||
*/ | ||
@@ -191,2 +211,10 @@ | ||
} | ||
/** | ||
* Creates the model and saves it on the backend | ||
* | ||
* The default behaviour is optimistic but this | ||
* can be tuned. | ||
*/ | ||
}, { | ||
@@ -228,2 +256,11 @@ key: 'create', | ||
} | ||
/** | ||
* Fetches the models from the backend. | ||
* | ||
* It uses `set` internally so you can | ||
* use the options to disable adding, changing | ||
* or removing. | ||
*/ | ||
}, { | ||
@@ -234,5 +271,7 @@ key: 'fetch', | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var label = 'fetching'; | ||
var _api$fetch = this.api.fetch(''); | ||
var _api$fetch = this.api.fetch(); | ||
@@ -247,3 +286,3 @@ var abort = _api$fetch.abort; | ||
_this5.request = null; | ||
_this5.set(data); | ||
_this5.set(data, options); | ||
}).catch(function (body) { | ||
@@ -254,2 +293,7 @@ _this5.request = null; | ||
} | ||
/** | ||
* Gets the ids of all the items in the collection | ||
*/ | ||
}, { | ||
@@ -256,0 +300,0 @@ key: 'ids', |
{ | ||
"name": "mobx-rest", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "REST conventions for mobx.", | ||
@@ -44,4 +44,4 @@ "repository": { | ||
"flow": "flow", | ||
"flow-stop": "flow stop" | ||
"check": "npm run flow && npm run link && npm test" | ||
} | ||
} |
@@ -24,4 +24,4 @@ # REST Mobx | ||
class Tasks extends Collection { | ||
basePath = `${apiPath}/tasks` | ||
model = Task | ||
basePath () { `${apiPath}/tasks` } | ||
model () { Task } | ||
} | ||
@@ -59,3 +59,3 @@ | ||
{ // Information at the resource level | ||
uuid: String, // Client side id. Used for optimistic updates | ||
uuid: String, // Client side id. Used for optimistic updates | ||
request: { // An ongoing request | ||
@@ -62,0 +62,0 @@ label: String, // Examples: 'updating', 'creating', 'fetching', 'destroying' ... |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37283
16
878