* Loads data from the storage and inits database connection. * This method must be executed before using `save` or `dispose`. * * @author Roman Pushkin (roman.pushkin@gmail.com) * @date 2016-05-20 * @version 1.1 * @since 0.1.0 * @return {Promise} promise that resol
()
| 112 | * @return {Promise} promise that resolves when data has been loaded. |
| 113 | */ |
| 114 | load() { |
| 115 | this.init(); |
| 116 | return new Promise((resolve) => { |
| 117 | this.db = firebaseDB.config().ref(this.firebasePath); |
| 118 | this.db.on('value', (snapshot) => { |
| 119 | const value = snapshot.val(); |
| 120 | |
| 121 | if (value) { |
| 122 | Object.assign(this.state, value); |
| 123 | } |
| 124 | |
| 125 | resolve(this); |
| 126 | }); |
| 127 | }); |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Updates the storage with current state. Will only overwrite the |
no test coverage detected