Declarative AJAX requests and automatic network state management for single-page applications
MIT License
Bot releases are hidden (Show)
Published by klis87 over 6 years ago
Reduced bundle size thanks to upgrade to Webpack 4 (only for UMD build).
Published by klis87 over 6 years ago
Reduced bundle size thanks to upgrade to Webpack 4 (only for UMD build).
Published by klis87 over 6 years ago
Fixed bug when using Axios
driver with FSA actions - error
action was incorrectly interpret as a request, because request
key in error
actions in payload
was set by Axios
, which collided with request
key from this library. Details can be seen in #101. Great thanks to @qizmaster for fixing this!
Published by klis87 over 6 years ago
Added an optional requestsPromiseMiddleware
, which promisifies request actions so you can wait for them to resolve from React components - see README for more info.
Apart from this:
BREAKING
- standardized request action structure - previously it was { type: 'A_TYPE', request: {} }
or { type: 'A_TYPE', requests: [{}, {}] }
, now batched request also go into request
key - { type: 'A_TYPE', request: [{}, {}] }
redux-saga
from the bundle, which was there due to Webpack misconfigurationPublished by klis87 over 6 years ago
This is quite an important release, focusing on making watchRequests
configurable. Before, watchRequests
wasn't flexible and powerful enough to support requests aborts, so lower level sendRequest
was necessery then. From now on, watchRequests
should be enough to handle aborts as well, so everyone can switch to auto mode with watchRequests
, which will greatly simplify sagas. See updated docs for more details.
Apart from this, following updates were made:
redux-act
and redux-actions
actions list to requestsReducer
resetOn
requestsReducer
doesn't touch pending counter - before subtle counter bugs could happen during requests abortsPublished by klis87 over 6 years ago
Added resetOn
to requestsReducer
config. Useful to reset state in your reducers easily. One nice possibility is to create your own requestsReducer
with a global behaviour, for example:
const myRequestsReducer = createRequestsReducer({ resetOn: ['LOGOUT'] });
// or const myRequestsReducer = createRequestsReducer({ resetOn: action => action.type === 'LOGOUT' });
Now, with 1 line of code, all your requests reducers will restart their state to initial one on user logout.
Of course, you can pass resetOn
to each requestsReducer
independently, which will overwrite global resetOn
(if defined).
Published by klis87 over 6 years ago
Additional interceptor updates:
BREAKING
: silent
flag in sendRequest
only stops actions from being dispatched, it doesn't affect interceptors
added runOnRequest
, runOnSuccess
, runOnError
and runOnAbort
flags to sendRequest
to control whether an interceptor should be called, all default to true
, useful to prevent endless loops when calling sendRequest
inside an interceptor
BREAKING
: changed return type of onError
interceptor to match type of sendRequest
, now you must return { response: someResponse }
or { error: someError }
, this change was made to allow shortcut like this:
function* onErrorSaga(error, action) {
if (weCanTryToRetry(error)) {
return yield call(sendRequest, action, { silent: true, runOnError: false });
}
return { error }
}
Published by klis87 over 6 years ago
improved interceptors:
BREAKING
: you have to return something in onRequest
, onResponse
and onError
interceptors, for example request config with added header in onRequest
, see interceptors
in new docsBREAKING
: in order to mark dispatchRequestAction
as true
in sendRequest
, you need to:
yield call(
sendRequest,
action,
{ dispatchRequestAction: true },
);
instead of
yield call(sendRequest, action, true);
new flag silent
which you can pass in config to sendRequest
(like dispatchRequestAction
), it tells sendRequest
not to dispatch any action and not to call any interceptor, false
as a default, useful inside interceptors
Published by klis87 over 6 years ago
successAction
, errorAction
and abortAction
to createRequestsInstance
config to allow actions customizationBREAKING
- renamed getSuccessAction
, getErrorAction
, getAbortAction
to success
, error
, abort
in requestsReducer
for consistencyrequestsReducer
config to its getData
and getError
"sideEffects": false
to package.json
for Webpack 4 tree-shakingPublished by klis87 over 6 years ago
From this version this mono repo switches to independend Lerna mode - this means that when 2 packages are updated at the same time, they could be updated to a different version.
Regarding updates for redux-saga-requests
package:
Published by klis87 over 6 years ago
The same as v0.5.0, version bumped to switch to independend Lerna mode.
Published by klis87 over 6 years ago
The same as v0.5.0, version bumped to switch to independend Lerna mode.
Published by klis87 almost 7 years ago
requestsReducer
and createRequestsReducer
Published by klis87 almost 7 years ago
Updated dependencies and peer-dependencies. You can safely upgrade without any application changes.
Published by klis87 almost 7 years ago
From this release this library switched to monorepo structure. It means, that redux-saga-requests
contains only the core functionality, and a client integration code like Axios
or Fetch API
were moved to dedicated packages:
redux-saga-requests-axios
redux-saga-requests-fetch
This gives a nice advantage that from now, you will have only a specific driver you use bundled with you application, saving precious bytes. So, to switch to this version, you will need to install not only redux-saga-requests
, but also a driver of your choice. Please see updated docs to see how it should be done.
Published by klis87 almost 7 years ago
Added Typescript types
Published by klis87 about 7 years ago
Initial release