@live-change/db
Advanced tools
Comparing version 0.3.17 to 0.3.18
@@ -14,2 +14,3 @@ const { TableWriter, LogWriter } = require('./queryUpdate.js') | ||
} | ||
unobserve(obs) {} | ||
async get() { | ||
@@ -32,2 +33,3 @@ return await (await this.#table).objectGet(this.#id) | ||
} | ||
unobserve(obs) {} | ||
onDelete(cb) {} | ||
@@ -49,2 +51,3 @@ async get() { | ||
} | ||
unobserve(obs) {} | ||
range(range) { | ||
@@ -51,0 +54,0 @@ return new RangeReader(this.#table, range) |
@@ -76,4 +76,4 @@ const ReactiveDao = require("@live-change/dao") | ||
async startObserver(factory) { | ||
if(this._queryReader.state != READER_READING) | ||
throw new Error(`Impossible to read data in ${readerStates[this._queryReader.state]} state`) | ||
/* if(this._queryReader.state != READER_READING) | ||
throw new Error(`Impossible to read data in ${readerStates[this._queryReader.state]} state`)*/ | ||
if(!this.#observable) this.#observable = this.observableFactory() | ||
@@ -84,3 +84,10 @@ const observer = factory(this._queryReader) | ||
await observer.readPromise() | ||
return observer | ||
} | ||
async unobserve(observer) { | ||
const index = this.#observers.indexOf(observer) | ||
if(index == -1) throw new Error("observer not found") | ||
this.#observers.splice(index, 1) | ||
;(await this.#observable).unobserve(observer) | ||
} | ||
async dispose() { | ||
@@ -87,0 +94,0 @@ this.disposed = true |
{ | ||
"name": "@live-change/db", | ||
"version": "0.3.17", | ||
"version": "0.3.18", | ||
"description": "Database with observable data for live queries", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
76257
2301