facebook-developer-circle-delhi / Ask-The-Community

This is an initiative where-in people can ask questions (directly or anonymously) as issues. People can then respond to them as comments. Once there is a satisfactory answer, we can close that issue down.
14 stars 1 forks source link

Help with Async Actions #6

Closed gaurav-gogia closed 6 years ago

gaurav-gogia commented 6 years ago

Hi all!

I have an async action and I wish to handle loading.

The async action is a simple post API call. I wish to start loading when the call is started and end loading when the call ends. Here is my code. I am able to dispatch the event and take care of API part but I'm not able to fix this loading issue. Someone told me to add the loading state to the store itself but I still can't figure it out. Please advise.

Thanks!

manishekaneja commented 6 years ago

I am assuming that you are able to handle the API call and your actual problem is related to loading status only.

Well, I would have preferred to go for a callback function instead of using async/await. So that, I can change the state of the loader again using that callback function in the API call.

But Since you are using async/await, Have you tried calling the "toggleLoading()" again after the "createLink()" call?

harshitjuneja commented 6 years ago

@DesmondANIMUS Make a post to the facebook group. Let's help you out there. Make sure you close this issue.

gaurav-gogia commented 6 years ago

Sure