Declarative AJAX requests and automatic network state management for single-page applications
MIT License
Bot releases are hidden (Show)
Published by klis87 over 4 years ago
See redux-saga-requests v0.27.0
Published by klis87 over 4 years ago
It was a long time since the last release, it was for a reason. This is a very big release,
which is the first step to achieve 1.0 version. It was not splited into smaller releases
not to trouble you constantly with breaking changes plus many things depended on each other.
The easiest way to see what changed is just to quickly read new Readme actually.
But to give you some hints, those are most notable changes:
watchRequests
, requestsReducer
, networkReducer
, all middleware from public API, it was replacedhandleRequests
function which returns all the necessary pieces like reducer, saga, middleware in the right order etc, which simplifies usage, and requires less documentationhandleRequests
returns requestsReducer
, but this is actually old networkReducer
, old requestsReducer
is not supported anymore, in order to support new features it had to be removed, not to mention supporting two different APIs was very bad for maintenance and docsgetQuery
and getMutation
are actually selectors now, not selector creators, selector creators are available asgetQuerySelector
and getMutationSelector
meta.resetOn
, replaced it with resetRequests
actionmeta.getData
and meta.updateData
payload, see docs or examples for current usagerequestKey
meta.requestKey
meta.requestKey
is also possible for queries, so you can store data for query with the same type independentlymeta.cacheKey
was removed, as meta.requestKey
serves the same purpose, but with or without cachemeta.cacheSize
with meta.requestsCapacity
due to the same reasonsendRequest
usage is encouraged only in intereceptors, also dispatchRequestAction
default is true
data
for now, no headers
or status
, usually we care about thosePublished by klis87 about 5 years ago
Fixed incorrect useMemo
dependencies array in useQuery
and useMutation
, which could cause some update issues on prop changes or PureComponent
optimisations.
Published by klis87 about 5 years ago
This is a very big release related to new networkReducer
, which is a manager of requestsReducer
s, so you won't need to write reducers for remote state anymore. Its introducing was followed with below changes:
data
like GET
requests, mutations can change data
and usually they use methods like POST
, PUT
, DELETE
, PATCH
createRequestsReducer
as you could just create requestsReducer
wrapper with functional programming techniquerequestsReducer
with a custom reducer, just use a separate reducer instead and merge them with selectors if neededdata
with ordinary actions, not only request onesnetworkReducer
which you can read about in the docs, I recommend to use it as probably requestsReducer
will be removed in future versionsgetQuery
and getMutation
selector creators, useful especially with networkReducer
, so you don't need to write selectors for your remote data manually, it requires reselect 4
as peer dependency so make sure you have it installedPublished by klis87 about 5 years ago
Changes too big to mentioned here, but related to redux-saga-requests
update to 0.26.0
. So only update redux-saga-requests-react
to 0.2.0
only if you upgraded redux-saga-requests
to 0.26.0
. Please refer docs to see how new API looks like, but we could sum up changes in the following points:
Operation
into Mutation
and RequestContainer
into Query
to match core library naming conventionuseQuery
and useMutation
Query
and Mutation
are connected by defaultPublished by klis87 about 5 years ago
Added headers
support, useful especially for authentication.
Published by klis87 over 5 years ago
Added server side rendering support with countServerRequests
and serverRequestsFilterMiddleware
.
Published by klis87 over 5 years ago
Performance and memory usage optimizations in requestsReducer
. Thanks @megawac !
Published by klis87 over 5 years ago
Improved cache support, namely added possibility to define cacheKey
and cacheSize
next to cache
in action meta, which allows to keep separate caches within the same request type per defined key. For instance:
const fetchBook = id => ({
type: FETCH_BOOK,
request: { url: `/books/${id}`},
meta: {
cache: true,
cacheKey: id, // must be string
cacheSize: 2 // optional with defined cacheKey to avoid cache growing too big
},
});
To achieve caching per key, internal caching implementation had to be changed a little, so in contract to previous version, now request and response actions are dispatched even when there is cache hit. Probably it won't affect you, but it might be useful to know. At the same time, sendRequest
will also return success
response from cache, no { cacheHit: true }
object.
There is another small change regarding success
action structure, namely now the whole server response
is added to action, not only data
, for instance:
{
type: 'DELETE_BOOK_SUCCESS',
response: { data: 'some data' },
data: 'some data',
meta: {
id: 1, // got from request action meta
requestAction: {
type: 'DELETE_BOOK',
request: {
url: '/books/1',
method: 'delete'
},
meta: {
id: 1,
},
},
},
}
Published by klis87 over 5 years ago
Allow using any action in resetOn
of requestsReducer
. Previously you couldn't use request action (which u pass to actionType
, or any response matching action (success, error, or abort), because reset case returned earlier, so request/response logic wasn't even executed.
Thanks to @megawac for the idea and PR!
Published by klis87 over 5 years ago
Added getDefaultData
to requestsReducer
config. Use instead of multiple
, if you want your initial data to be something else than null
or []
, for instance () => ({ value: null })
, set as multiple => (multiple ? [] : null)
by default, so this is backward compatible change.
Thanks to @megawac for the idea and PR!
Published by klis87 over 5 years ago
First release of new React bindings to redux-saga-requests
. See https://github.com/klis87/redux-saga-requests/tree/master/packages/redux-saga-requests-react for more info.
Published by klis87 almost 6 years ago
Small changes which allowed adding GraphQL driver:
takeLatest
(like REST GET), mutations as takeEvery
(like REST POST PUT DELETE etc.)request.query
are recognized as request actionsPublished by klis87 almost 6 years ago
A new driver which allows to use redux-saga-requests
with GraphQL! See docs and example for more info. It requires redux-saga-requests
at least 0.22.0
version.
Published by klis87 almost 6 years ago
Updated Typescript types
Published by klis87 almost 6 years ago
Updated Typescript types.
Published by klis87 almost 6 years ago
Updated Typescript types.
Published by klis87 almost 6 years ago
data
in reducers before you get server response, see the bottom of https://github.com/klis87/redux-saga-requests#reducers-arrow_up
jest
, which simplified configuration, allowed to get rid of too many dev dependencies (mocha, chai, sinon, nyc
)Published by klis87 almost 6 years ago
Added support to redux-saga
1.0.0-beta version. Note, that this is a backward compatible change, it still supports 0.16
version!
Published by klis87 almost 6 years ago
meta.asPromise: false
to overwrite requestsPromiseMiddleware
with auto
for a given action, thanks to @nemosupremo for the idea and PR!meta.runByWatcher
flag, which can be used to disable handling it by watchRequests
, which is by the way used by default for sendRequest
with dispatchRequestAction: true
to avoid duplicated requests when you use both watchRequests
and sendRequest
watchRequests
, so if you need to override global abortOn
and takeLatest
for an action, you can use meta
, for example:const fetchBooks = () => ({
type: FETCH_BOOKS,
request: {
url: '/books',
},
meta: {
takeLatest: false,
abortOn: 'LOGOUT',
},
});
runOn...
options of sendRequests
, so for most cases you don't even need to worry about them, see more details in readme