Skip to content

Commit

Permalink
Revert "chore: Introduce a way to access value of asyncComputed witho…
Browse files Browse the repository at this point in the history
…ut causing promise to be called"

This reverts commit d5e78c6.
  • Loading branch information
jansav committed Mar 18, 2024
1 parent d5e78c6 commit b963784
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 119 deletions.
2 changes: 0 additions & 2 deletions packages/mobx-utils/src/asyncComputed/asyncComputed.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ export default ({
return {
value: originalComputed,

untrackedValue: computed(() => syncValueBox.get()),

invalidate: () => {
runInAction(() => {
invalidateAtom.reportChanged();
Expand Down
117 changes: 0 additions & 117 deletions packages/mobx-utils/src/asyncComputed/asyncComputed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe('asyncComputed', () => {
let someMock;
let someAsyncComputed;
let someObservable;
let untrackedValue;

beforeEach(() => {
someMock = asyncFn();
Expand All @@ -23,16 +22,6 @@ describe('asyncComputed', () => {

valueWhenPending: 'some-pending-value',
});

observe(
someAsyncComputed.untrackedValue,

changed => {
untrackedValue = changed.newValue;
},

true,
);
});

it('given invalidated before observation, when observed, does not throw', () => {
Expand All @@ -43,14 +32,6 @@ describe('asyncComputed', () => {
}).not.toThrow();
});

it('untracked value is pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

it('does not compute yet', () => {
expect(someMock).not.toHaveBeenCalled();
});

describe('when only status is observed but not value', () => {
beforeEach(() => {
observe(someAsyncComputed.pending, () => {});
Expand All @@ -60,10 +41,6 @@ describe('asyncComputed', () => {
expect(someMock).toHaveBeenCalled();
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

describe('when observed promise resolves', () => {
beforeEach(async () => {
await someMock.resolve('some-promise-result');
Expand All @@ -75,10 +52,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(false);
});

it('untracked value is the result of promise', () => {
expect(untrackedValue).toBe('some-promise-result');
});

it('when value is observed, observed value is the result of promise', () => {
let observedValue;

Expand Down Expand Up @@ -121,10 +94,6 @@ describe('asyncComputed', () => {
expect(someMock).toHaveBeenCalledWith('some-initial-value');
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

describe('when observed promise has not resolved yet', () => {
it('observed value is pending value', async () => {
expect(observedValue).toBe('some-pending-value');
Expand All @@ -136,10 +105,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(true);
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

describe('but another change is observed', () => {
beforeEach(() => {
someMock.mockClear();
Expand All @@ -157,10 +122,6 @@ describe('asyncComputed', () => {
expect(observedValue).toBe('some-pending-value');
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

it('observes as pending', () => {
const pendingStatus = getPendingStatus(someAsyncComputed);

Expand All @@ -179,10 +140,6 @@ describe('asyncComputed', () => {
expect(observedValue).toBe('some-pending-value');
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

it('still observes as pending', () => {
const pendingStatus = getPendingStatus(someAsyncComputed);

Expand All @@ -197,10 +154,6 @@ describe('asyncComputed', () => {
);
});

it('untracked value is the result of latest promise', () => {
expect(untrackedValue).toBe('some-latest-promise-result');
});

it('observed value is result of latest promise', async () => {
expect(observedValue).toBe('some-latest-promise-result');
});
Expand Down Expand Up @@ -230,10 +183,6 @@ describe('asyncComputed', () => {
expect(observedValue).toBe('some-promise-result');
});

it('untracked value is the result of promise', () => {
expect(untrackedValue).toBe('some-promise-result');
});

it('is no longer pending', () => {
const pendingStatus = getPendingStatus(someAsyncComputed);

Expand Down Expand Up @@ -263,10 +212,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(true);
});

it('untracked value is the pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

it('observed value is pending value', () => {
expect(observedValue).toBe('some-pending-value');
});
Expand All @@ -289,10 +234,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(true);
});

it('untracked value is the pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

it('observed value is pending value', () => {
expect(observedValue).toBe('some-pending-value');
});
Expand Down Expand Up @@ -330,7 +271,6 @@ describe('asyncComputed', () => {
let someMock;
let someAsyncComputed;
let someObservable;
let untrackedValue;

beforeEach(() => {
someMock = asyncFn();
Expand All @@ -347,16 +287,6 @@ describe('asyncComputed', () => {
// Notice: no pending value.
// valueWhenPending: 'some-pending-value',
});

observe(
someAsyncComputed.untrackedValue,

changed => {
untrackedValue = changed.newValue;
},

true,
);
});

it('given invalidated before observation, when observed, does not throw', () => {
Expand Down Expand Up @@ -551,10 +481,6 @@ describe('asyncComputed', () => {
expect(observedValue).toBe(undefined);
});

it('untracked value is pending value', () => {
expect(untrackedValue).toBe(undefined);
});

it('recomputes', () => {
expect(someMock).toHaveBeenCalledWith('some-changed-value');
});
Expand All @@ -577,10 +503,6 @@ describe('asyncComputed', () => {
expect(observedValue).toBe(undefined);
});

it('untracked value is pending value', () => {
expect(untrackedValue).toBe(undefined);
});

it('recomputes', () => {
expect(someMock).toHaveBeenCalledWith('some-initial-value');
});
Expand Down Expand Up @@ -614,7 +536,6 @@ describe('asyncComputed', () => {
let someMock;
let someAsyncComputed;
let someObservable;
let untrackedValue;

beforeEach(() => {
someMock = asyncFn();
Expand All @@ -632,16 +553,6 @@ describe('asyncComputed', () => {

betweenUpdates: 'show-latest-value',
});

observe(
someAsyncComputed.untrackedValue,

changed => {
untrackedValue = changed.newValue;
},

true,
);
});

it('given invalidated before observation, when observed, does not throw', () => {
Expand All @@ -661,19 +572,11 @@ describe('asyncComputed', () => {
expect(someMock).toHaveBeenCalled();
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

describe('when observed promise resolves', () => {
beforeEach(async () => {
await someMock.resolve('some-promise-result');
});

it('untracked value is the result of promise', () => {
expect(untrackedValue).toBe('some-promise-result');
});

it('is no longer pending', () => {
const pendingStatus = getPendingStatus(someAsyncComputed);

Expand Down Expand Up @@ -737,10 +640,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(true);
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

describe('but another change is observed', () => {
beforeEach(() => {
someMock.mockClear();
Expand All @@ -764,10 +663,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(true);
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

describe('when the obsolete promise resolves', () => {
beforeEach(async () => {
await someMock.resolveSpecific(
Expand All @@ -786,10 +681,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(true);
});

it('untracked value is still pending value', () => {
expect(untrackedValue).toBe('some-pending-value');
});

describe('when the latest promise resolves', () => {
beforeEach(async () => {
await someMock.resolveSpecific(
Expand Down Expand Up @@ -833,10 +724,6 @@ describe('asyncComputed', () => {
expect(pendingStatus).toBe(false);
});

it('untracked value is the result of promise', () => {
expect(untrackedValue).toBe('some-promise-result');
});

it('when observed again, still does not recompute', () => {
someMock.mockClear();

Expand Down Expand Up @@ -865,10 +752,6 @@ describe('asyncComputed', () => {
expect(changeOfValueIsObserved).toBe(false);
});

it('untracked value is the result of promise', () => {
expect(untrackedValue).toBe('some-promise-result');
});

it('observed value remains the latest value', () => {
expect(observedValue).toBe('some-promise-result');
});
Expand Down

0 comments on commit b963784

Please sign in to comment.