Quantcast
Channel: How to dispatch a Redux action with a timeout? - Stack Overflow
Browsing latest articles
Browse All 15 View Live

Answer by Mohmmad Ebrahimi Aval for How to dispatch a Redux action with a...

It is simple. Use trim-redux package and write like this in componentDidMount or other place and kill it in componentWillUnmount. componentDidMount() { this.tm = setTimeout(function() { setStore({ age:...

View Article



Answer by Vanuan for How to dispatch a Redux action with a timeout?

Why should it be so hard? It's just UI logic. Use a dedicated action to set notification data: dispatch({ notificationData: { message: 'message', expire: +new Date() + 5*1000 } }) and a dedicated...

View Article

Answer by Bloomca for How to dispatch a Redux action with a timeout?

Redux itself is a pretty verbose library, and for such stuff you would have to use something like Redux-thunk, which will give a dispatch function, so you will be able to dispatch closing of the...

View Article

Answer by cnexans for How to dispatch a Redux action with a timeout?

I understand that this question is a bit old but I'm going to introduce another solution using redux-observable aka. Epic. Quoting the official documentation: What is redux-observable? RxJS 5-based...

View Article

Answer by Alireza for How to dispatch a Redux action with a timeout?

The appropriate way to do this is using Redux Thunk which is a popular middleware for Redux, as per Redux Thunk documentation: "Redux Thunk middleware allows you to write action creators that return a...

View Article


Answer by Tyler Long for How to dispatch a Redux action with a timeout?

A repository with sample projects Current there are four sample projects: Writing Async Code Inline Extracting Async Action Creator Use Redux Thunk Use Redux Saga The accepted answer is awesome. But...

View Article

Answer by Yash for How to dispatch a Redux action with a timeout?

If you want timeout handling on selective actions, you can try the middleware approach. I faced a similar problem for handling promise based actions selectively and this solution was more flexible....

View Article

Answer by Jeff Barczewski for How to dispatch a Redux action with a timeout?

After trying the various popular approaches (action creators, thunks, sagas, epics, effects, custom middleware), I still felt that maybe there was room for improvement so I documented my journey in...

View Article


Image may be NSFW.
Clik here to view.

Answer by Sebastien Lorber for How to dispatch a Redux action with a timeout?

Using Redux-saga As Dan Abramov said, if you want more advanced control over your async code, you might take a look at redux-saga. This answer is a simple example, if you want better explanations on...

View Article


Answer by Jean-Jacques Dubray for How to dispatch a Redux action with a timeout?

I would recommend also taking a look at the SAM pattern. The SAM pattern advocates for including a "next-action-predicate" where (automatic) actions such as "notifications disappear automatically after...

View Article

Answer by Dan Abramov for How to dispatch a Redux action with a timeout?

Don’t fall into the trap of thinking a library should prescribe how to do everything. If you want to do something with a timeout in JavaScript, you need to use setTimeout. There is no reason why Redux...

View Article

Answer by Fatih Erikli for How to dispatch a Redux action with a timeout?

You can do this with redux-thunk. There is a guide in redux document for async actions like setTimeout.

View Article

How to dispatch a Redux action with a timeout?

I have an action that updates notification state of my application. Usually, this notification will be an error or info of some sort. I need to then dispatch another action after 5 seconds that will...

View Article


Answer by Irfanullah Jan for How to dispatch a Redux action with a timeout?

This may be a bit off-topic but I want to share it here because I simply wanted to remove Alerts from state after a given timeout i.e. auto hiding alerts/notifications.I ended up using setTimeout()...

View Article

Answer by Audrey for How to dispatch a Redux action with a timeout?

Redux actions can just return a plain object, not functions, callbacks, or asynchronous processes. For dispatching them through web API such as timeout() method you have to use redux-thunk middleware....

View Article

Browsing latest articles
Browse All 15 View Live




Latest Images