Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

72 expose query props via an API similar toRemoteData #78

Merged
merged 13 commits into from
Mar 29, 2019

Conversation

fes300
Copy link
Contributor

@fes300 fes300 commented Jan 4, 2019

Closes #72

Test Plan

tests performed

as a test I used the new version in a Create React App app. I created 3 queries:
importantQuery: resolves very quickly
uselessQueryTakingVeryLong: slow query that resolves in a few seconds
yetAnotherQueryThatFails: failing query

  • I verfied that at first paint they are all RemotePendings:
    image
  • I verfied that at second paint the quick one is RemoteSuccess and the slow one is RemotePending:
    image
  • I verfied that at third paint both the slow and the fast one are RemoteSuccess:
    image
  • I verfied that if I invalidate the long query it reloads correctly:
    image
  • I verfied that the folding method in the queries works as expected:
    image

@nemobot nemobot added the WIP label Jan 4, 2019
@fes300 fes300 changed the title 72 expose query props via 72 expose query props via an API similar toRemoteData Jan 4, 2019
@fes300 fes300 requested a review from giogonzo January 4, 2019 14:48
@fes300 fes300 changed the title 72 expose query props via an API similar toRemoteData [DO NOT MERGE]72 expose query props via an API similar toRemoteData Jan 4, 2019
@fes300 fes300 changed the title [DO NOT MERGE]72 expose query props via an API similar toRemoteData [DO NOT MERGE] 72 expose query props via an API similar toRemoteData Jan 4, 2019
@fes300 fes300 changed the base branch from master to remote-data January 4, 2019 14:56
@fes300 fes300 changed the title [DO NOT MERGE] 72 expose query props via an API similar toRemoteData 72 expose query props via an API similar toRemoteData Jan 4, 2019
@@ -2,7 +2,7 @@
"include": ["src"],
"compilerOptions": {
"lib": [
"es2015"
"es2017"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to use Object.values

@@ -43,8 +40,6 @@ describe('declareQueries', () => {
const mounted = mount(<WithFoo token="foo" />);
expect(mounted).toMatchSnapshot();
expect(render.mock.calls.length).toBe(3);
expect(render.mock.calls[2][0].foo.ready).toBe(true);
expect(render.mock.calls[2][0].foo.loading).toBe(false);
expect(render.mock.calls[2][0].foo.value).toBe('foo');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was very undecided if I should test more but then I figured it could be a different PR

src/index.d.ts Outdated
ready: true;
value: DeclKey;
}) & {
loading: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fes300 this typedef seems to be a bit off / outdated: shouldn't it just be QueryInnerProp = RemoteData<Error, Decl[k]['_P']>?

Also, what should Error be in practice? Without changing how we write queries just yet, this could be set to Error or unknown I think, nothing more specific

Copy link
Contributor Author

@fes300 fes300 Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, I initially left it there because I wrongly thought that it was the type returned from avenger and then forgot to change it...

Copy link
Contributor Author

@fes300 fes300 Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the moment Error is whatever value the promise is rejected with, in my idea it could be anything as it is defined by the user

@giogonzo giogonzo self-assigned this Mar 29, 2019
@giogonzo giogonzo merged commit 55d97c9 into remote-data Mar 29, 2019
@nemobot
Copy link

nemobot commented Mar 29, 2019

@nemobot nemobot removed the WIP label Mar 29, 2019
@giogonzo giogonzo deleted the 72-expose_query_props_via branch March 29, 2019 13:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants