statetree
Library for creation data-oriented architecture of web applications.
Installation
$ npm install --save-dev statetree
AsyncData
AsyncData is a wrapper for objects that are often being updated, changed and synced.
Initialization
var User = ;
Properties
User_loaded // identificator that the object is loaded or notUser_updating // identificator that the object is updating or notUser_changed // identificator that the object has been changed locally (and is not saved)User_old_value // contains old version of the objectUser_error //User_error_message //
Methods
getPromise
Returns a Promise object which you can use to know if the data has been loaded/updated.
User
_update
Calls resolve when data is received from the server, merges data.
User
isChanged
Checks if the object has been changed locally.
ifUser console;
getChangedFields
Returns fields that have been changed locally.
User
revert
Revert old value
User