-
Notifications
You must be signed in to change notification settings - Fork 0
72 expose query props via an API similar toRemoteData
#78
Conversation
1e55d16
to
ed9561f
Compare
RemoteData
RemoteData
RemoteData
RemoteData
RemoteData
RemoteData
RemoteData
ed9561f
to
d61b6f6
Compare
@@ -2,7 +2,7 @@ | |||
"include": ["src"], | |||
"compilerOptions": { | |||
"lib": [ | |||
"es2015" | |||
"es2017" |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
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 quicklyuselessQueryTakingVeryLong
: slow query that resolves in a few secondsyetAnotherQueryThatFails
: failing queryRemotePendings
:RemoteSuccess
and the slow one isRemotePending
:RemoteSuccess
:folding
method in the queries works as expected: