dataflux 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/dist/Obj.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -481,18 +481,18 @@ The store emits the following events:
|
|
|
481
481
|
Each object created is enriched with the following methods.
|
|
482
482
|
|
|
483
483
|
|
|
484
|
-
| Method | Description
|
|
485
|
-
|
|
486
|
-
| getId() | It returns a unique ID used by the store to identify the object. The ID is unique inside a single model. Be aware, `object.id` and `objet.getId()` may return different values, since store's IDs can be different from the one of the REST API.
|
|
487
|
-
| set(attribute, value, hidden) | A method to set an attribute to the object. It provides some advantages compared to doing `object.attribute = value`, these are discussed in [below](#editing-objects).
|
|
488
|
-
| save() | Method to save the object. You can do `store.save()` instead.
|
|
489
|
-
| destroy() | Method to delete the object. You can do `store.delete()` instead.
|
|
490
|
-
| get(attribute)
|
|
491
|
-
| getRelation(model, filterFunction) | To get all the objects respecting a specific relation with this object (see [model relations](#model-relations)).
|
|
492
|
-
| toJSON() | It returns a pure JSON representation of the object.
|
|
493
|
-
| toString() | It returns a string representation of the object.
|
|
494
|
-
| getFingerprint() | It returns a hash of the object. The hash changes at every change of the object or of any nested object. Useful to detect object changes.
|
|
495
|
-
| getModel() | It returns the model of this object. Mostly useful to do `object.getModel().getType()` and obtain a string defining the type of the object.
|
|
484
|
+
| Method | Description |
|
|
485
|
+
|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
486
|
+
| getId() | It returns a unique ID used by the store to identify the object. The ID is unique inside a single model. Be aware, `object.id` and `objet.getId()` may return different values, since store's IDs can be different from the one of the REST API. |
|
|
487
|
+
| set(attribute, value, hidden) | A method to set an attribute to the object. It provides some advantages compared to doing `object.attribute = value`, these are discussed in [below](#editing-objects). |
|
|
488
|
+
| save() | Method to save the object. You can do `store.save()` instead. |
|
|
489
|
+
| destroy() | Method to delete the object. You can do `store.delete()` instead. |
|
|
490
|
+
| get(attribute, defaultValue) | Method to retrieve the value of an attribute. It does not provide any advantage compared to accessing directly the attribute (e.g., `author.name`); except for hidden fields, which can be retrieved only with the `.get` method. Additionally, you can provide a default value as a second parameter in case the object doesn't have that attribute. |
|
|
491
|
+
| getRelation(model, filterFunction) | To get all the objects respecting a specific relation with this object (see [model relations](#model-relations)). |
|
|
492
|
+
| toJSON() | It returns a pure JSON representation of the object. |
|
|
493
|
+
| toString() | It returns a string representation of the object. |
|
|
494
|
+
| getFingerprint() | It returns a hash of the object. The hash changes at every change of the object or of any nested object. Useful to detect object changes. |
|
|
495
|
+
| getModel() | It returns the model of this object. Mostly useful to do `object.getModel().getType()` and obtain a string defining the type of the object. |
|
|
496
496
|
|
|
497
497
|
## Editing objects
|
|
498
498
|
The option `autoSave` can be `true`, `false`, or a number (milliseconds).
|
package/dist/Obj.js
CHANGED
|
@@ -76,8 +76,10 @@ var Obj = /*#__PURE__*/_createClass(function Obj(values, _model) {
|
|
|
76
76
|
return (0, _fingerprint["default"])(_this.toJSON());
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
_defineProperty(this, "get", function (attribute) {
|
|
80
|
-
|
|
79
|
+
_defineProperty(this, "get", function (attribute, defaultValue) {
|
|
80
|
+
var _ref, _classPrivateFieldGet2;
|
|
81
|
+
|
|
82
|
+
return (_ref = (_classPrivateFieldGet2 = _classPrivateFieldGet(_this, _setHidden)[attribute]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : _this[attribute]) !== null && _ref !== void 0 ? _ref : defaultValue;
|
|
81
83
|
});
|
|
82
84
|
|
|
83
85
|
_defineProperty(this, "getRelation", function (type, filterFunction) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dataflux",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "DataFlux, automatically interfaces with your REST APIs to create a 2-way-synced local data store. Transparently manages data propagation in the React state.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": "dist/index.js",
|