Skip to content

Commit

Permalink
Return observable in data property and document
Browse files Browse the repository at this point in the history
  • Loading branch information
0x80 committed Jun 2, 2022
1 parent 015da36 commit 6afcdc2
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,17 @@ export class ObservableDocument<T> {
return this;
}

get data(): T /* | undefined */ {
assert(this.documentRef && this._data, "No data available");
// if (!this.documentRef || this._data === NO_DATA) return;

return toJS(this._data);
get data(): T {
assert(this._data, "No data available");
return this._data;
}

get document(): Document<T> {
assert(this.documentRef && this._data, "No document available");

/**
* For document we return the data as non-observable by converting it to a
* JS object. Not sure if we need this but seems logical. If you want to
* observable data you can use the data property directly.
*/
return {
id: this.documentRef.id,
data: this.data,
data: this._data,
ref: this.documentRef,
};
}
Expand Down

0 comments on commit 6afcdc2

Please sign in to comment.