Releases: klis87/redux-requests
@redux-requests/core v1.1.1
Made type
property or RequestAction
interface optional. When it is required, for some reason Typescript complains when using it with redux-smart-actions
, it might be a Typescript bug but for now this is enough to make things work.
@redux-requests/react v1.1.0
The same as in the @redux-requests/core v1.1.0
, just for useQuery
and Query
.
@redux-requests/core v1.1.0
Massively improved Typescript types. Added generics to RequestAction
type, so that you can define data structure there, for example:
import { RequestAction } from '@redux-requests/core';
const fetchBooks: () => RequestAction<
{ raw: boolean },
{ parsed: boolean }
> = () => {
return {
type: 'FETCH_BOOKS',
request: {
url: '/books',
},
meta: {
getData: data => ({ parsed: data.raw }),
},
};
};
2nd generic defaults to 1st, it is useful when you transform data in getData
.
Ok, but why do we even care? It would be easy to just add types to getData
if we needed.
The answer is, that those data types are now automatically inferred in querySelector
and getQuerySelector
if you define request actions with libraries like redux-smart-actions
, redux-act
or redux-actions
- that's it, when you don't write constants and you pass actions themselves as type
.
So, if you do:
import { RequestAction } from '@redux-requests/core';
import { createSmartAction } from 'redux-smart-actions';
const fetchBooks: () => RequestAction<
{ raw: boolean },
{ parsed: boolean }
> = createSmartAction(() => {
return {
request: {
url: '/books',
},
meta: {
getData: data => ({ parsed: data.raw }),
},
};
});
then if you use getQuery
:
const booksQuery = getQuery(state, { type: fetchBooks });
then booksQuery.data
will be automatically typed! Even if you have only fetchBooks
written in typescript, but for some reason getQuery
is in js file, then still you will get this like autocomplete for free! So the point is, add type only in request actions and enjoy types automatically everywhere you read query state.
@redux-requests/core v1.0.0
First major release! This is really the same as the previous version, just some dependencies like Babel or Webpack were updated so it should be safe to upgrade.
@redux-requests/fetch v0.12.0
Added headers
and status
keys to response (next to data
).
@redux-requests/core v0.31.0
- changed function signature of
clearRequestsCache
to matchabortRequests
andresetRequests
for consistence - allowed possibility to add more keys to response than
data
in batched requests - moved docs to https://redux-requests.klisiczynski.com
redux-requests/axios v0.10.0
Added headers
and status
keys to response (next to data
).
@redux-requests/graphql v0.4.2
Fixed request abort handling, which was not properly propagated to the core.
@redux-requests/mock v0.4.0
Successful responses and errors are defined in actions themselves, not passed to createDriver
anymore.
@redux-requests/core v0.30.1
- added
meta.cacheKey
- if it changes, cache is invalidated - added showcase example
- added logo - thx to @strdr4605 and his friend!