Skip to content

Commit

Permalink
Remove auto make observable
Browse files Browse the repository at this point in the history
  • Loading branch information
0x80 committed Apr 30, 2022
1 parent 3934dad commit 163323c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
21 changes: 11 additions & 10 deletions src/collection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {
makeAutoObservable,
action,
computed,
makeObservable,
observable,
onBecomeObserved,
onBecomeUnobserved,
runInAction,
Expand Down Expand Up @@ -66,15 +69,13 @@ export class ObservableCollection<T> {
queryCreatorFn?: QueryCreatorFn,
options?: Options,
) {
// makeObservable(this, {
// documents: observable,
// isLoading: observable,
// isEmpty: computed,
// hasDocuments: computed,
// attachTo: action,
// });

makeAutoObservable(this);
makeObservable(this, {
documents: observable,
isLoading: observable,
isEmpty: computed,
hasDocuments: computed,
attachTo: action,
});

this.initializeReadyPromise();
/**
Expand Down
23 changes: 13 additions & 10 deletions src/document.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {
action,
computed,
makeAutoObservable,
makeObservable,
observable,
onBecomeObserved,
onBecomeUnobserved,
runInAction,
Expand Down Expand Up @@ -42,7 +46,7 @@ type SourceType<T> =
| Document<T>;

export class ObservableDocument<T> {
private _data: T | typeof NO_DATA = NO_DATA;
_data: T | typeof NO_DATA = NO_DATA;
isLoading = false;

private debugId = createUniqueId();
Expand All @@ -61,15 +65,14 @@ export class ObservableDocument<T> {
onError?: (err: Error) => void;

public constructor(source?: SourceType<T>, options?: Options) {
// makeObservable(this, {
// _data: observable,
// isLoading: observable,
// data: computed,
// document: computed,
// attachTo: action,
// hasData: computed,
// })
makeAutoObservable(this);
makeObservable(this, {
_data: observable,
isLoading: observable,
data: computed,
document: computed,
attachTo: action,
hasData: computed,
});

if (options) {
this.isDebugEnabled = options.debug || false;
Expand Down

0 comments on commit 163323c

Please sign in to comment.