redux-observable | Redux RxJava Observable middleware for Kotlin | Reactive Programming library
kandi X-RAY | redux-observable Summary
kandi X-RAY | redux-observable Summary
Redux RxJava Observable middleware for Kotlin.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of redux-observable
redux-observable Key Features
redux-observable Examples and Code Snippets
Community Discussions
Trending Discussions on redux-observable
QUESTION
I have to pretty weird case to handle.
We have to few boxes, We can call some action on every box. When We click the button inside the box, we call some endpoint on the server (using axios
). Response from the server return new updated information (about all boxes, not the only one on which we call the action).
Issue: If user click submit button on many boxes really fast, the request call the endpoints one by one. It's sometimes causes errors, because it's calculated on the server in the wrong order (status of group of boxes depends of single box status). I know it's maybe more backend issue, but I have to try fix this on frontend.
Proposal fix:
In my opinion in this case the easiest fix is disable every submit
button if any request in progress. This solution unfortunately is very slow, head of the project rejected this proposition.
What we want to goal: In some way We want to queue the requests without disable every button. Perfect solution for me at this moment:
- click first button - call endpoint, request pending on the server.
- click second button - button show spinner/loading information without calling endpoint.
- server get us response for the first click, only then we really call the second request.
I think something like this is huge antipattern, but I don't set the rules. ;)
I was reading about e.g. redux-observable
, but if I don't have to I don't want to use other middleware for redux
(now We use redux-thunk
). Redux-saga
it will be ok, but unfortunately I don't know this tool. I prepare simple codesandbox example (I added timeouts in redux
actions for easier testing).
I have only one stupid proposal solution. Creating a array of data needs to send correct request, and inside useEffect
checking if the array length is equal to 1. Something like this:
ANSWER
Answered 2021-Jun-10 at 21:53I agree with your assessment that we ultimately need to make changes on the backend. Any user can mess with the frontend and submit requests in any order they want regardless how you organize it.
I get it though, you're looking to design the happy path on the frontend such that it works with the backend as it is currently.
It's hard to tell without knowing the use-case exactly, but there may generally be some improvements we can make from a UX perspective that will apply whether we make fixes on the backend or not.
Is there an endpoint to send multiple updates to? If so, we could debounce our network call to submit only when there is a delay in user activity.
Does the user need to be aware of order of selection and the impacts thereof? If so, it sounds like we'll need to update frontend to convey this information, which may then expose a natural solution to the situation.
It's fairly simple to create a request queue and execute them serially, but it seems potentially fraught with new challenges.
E.g. If a user clicks 5 checkboxes, and order matters, a failed execution of the second update would mean we would need to stop any further execution of boxes 3 through 5 until update 2 could be completed. We'll also need to figure out how we'll handle timeouts, retries, and backoff. There is some complexity as to how we want to convey all this to the end user.
Let's say we're completely set on going that route, however. In that case, your use of Redux for state management isn't terribly important, nor is the library you use for sending your requests.
As you suggested, we'll just create an in-memory queue of updates to be made and dequeue serially. Each time a user makes an update to a box, we'll push to that queue and attempt to send updates. Our processEvents
function will retain state as to whether a request is in motion or not, which it will use to decide whether to take action or not.
Each time a user clicks a box, the event is added to the queue, and we attempt processing. If processing is already ongoing or we have no events to process, we don't take any action. Each time a processing round finishes, we check for further events to process. You'll likely want to hook into this cycle with Redux and fire new actions to indicate event success and update the state and UI for each event processed and so on. It's possible one of the libraries you use offer some feature like this as well.
QUESTION
I'm making an app that lets the user select snacks from a list of available snacks. The snacks are loaded from an external API.
I'm using redux-observable
to "listen" for actions and then dispatch the appropriate API requests. Here's my existing code, with a comment on the problematic line of code:
ANSWER
Answered 2021-May-30 at 03:33If I use filter
and .match
then the correct type is inferred:
QUESTION
Aight.. so im pretty new with redux toolkit and I want to catch ALL pending actions in one slice to basically show a loading modal. I know we can do this with redux-saga
and probably redux-observable
Soooooo instead of
...ANSWER
Answered 2021-May-13 at 18:15You can use the matching utilities included in RTK:
QUESTION
I am testing the following redux-observable epic:
...ANSWER
Answered 2021-Apr-27 at 07:28Unfortunately the TestScheduler
is stateful, so you're seeing the effects of previously run tests.
I've created a fork of your project that initialises an instance per test.
QUESTION
I get the following errors when setting up middleware. Using Redux observable/Redux toolkit. Any inputs on why this is happenening?
Following below repo set-up. https://github.com/beast911/react-redux-observables-typescript
...ANSWER
Answered 2021-Mar-15 at 11:06Most Redux Toolkit apis should not be called with manually specified generics.
By calling return configureStore(...
you actually erase all information about middlewares from your store. Skip the generic, just call return configureStore(...
and let TypeScript infer the correct types from usage.
QUESTION
Simple demo of antd form onSubmit is not working
https://ant.design/components/form/#components-form-demo-register
The onChange of field components are validated, but onFinish is not called on click of submit.
Is it because of lodash/webpack or react version dependency issue.
This is happening on lens electronjs application and the dependencies are below:
...ANSWER
Answered 2021-Feb-24 at 17:05Not sure for what reason, the submit button inside form not triggered. Hence handled with external submit validation function.
QUESTION
In my scenario, when the app loads I dispatch an action that starts an epic to create an API instance, which is necessary to make other API calls:
...ANSWER
Answered 2021-Feb-22 at 15:29So, if api
is what you need to wait for in searchItem
epic, I think this would be an approach:
QUESTION
This is the code snippet for what I am trying to do. currentUser is updated when the user signs in or logs out.
...ANSWER
Answered 2021-Jan-04 at 06:15Perhaps this option will solve your problem:
QUESTION
I'm not sure how to write a React observable epic with Redux Toolkit and Typescript.
Suppose I have this authSlice:
...ANSWER
Answered 2020-Oct-13 at 19:18The problem is that redux-toolkit obscures the actions so it's hard to know what the action types are. Whereas in a traditional redux setup they are just a bunch of constants.
QUESTION
I am using redux-observable and want to retry 3 times whenever an API call throws error.
But it doesn't retry, it has only one http request sent.
I made up a sample calling github user api to find a user, if you provide a non exist username like This doesn't exist
then it will throw an 404 error. I have added retry(3)
but it doesn't retry.
You can find the codes on codesandbox
...ANSWER
Answered 2020-Oct-09 at 11:56Move your retry up into the inner observable, like so:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install redux-observable
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page