react-top-loading-bar icon indicating copy to clipboard operation
react-top-loading-bar copied to clipboard

Make it work with HTTP Calls

Open hasante opened this issue 5 years ago • 5 comments

You got me, but please add this feature it will go a long way

hasante avatar May 28 '20 20:05 hasante

what do you mean http calls ? You can "simulate" http calls, like start the bar on request beginning, and end it on result. You can even use redux

klendi avatar May 29 '20 14:05 klendi

I have seen a react package like this that works with Redux to make HTTP calls possible.

I was thinking maybe you could do this for only react.js without the need to integrating Redux. What are your taughts?

hasante avatar May 29 '20 14:05 hasante

Yeah but there are can multiple http calls, or 3 calls async, loading bar would go crazy, I don't think it's a good idea. It's more controllable or appropriate to only activate the bar when needed. It gives more control. And more popular bars don't have that. Bars are meant to have start -> end, the loading is just a simulation, we can't track http calls progress that much. Also you have project examples where I used the bar on my other projects.

klendi avatar May 29 '20 15:05 klendi

Well, I am talking of user-initiated calls, but until you have tried looking into it and prioritizing a part of the scenario. I am not sure you can straightaway assume that has to be all you state up here.

This can serve as a start: https://github.com/aitboudad/ngx-loading-bar/blob/master/packages/http-client/README.md

React Redux version: https://github.com/mironov/react-redux-loading-bar

The importance from my perspective is there is a load of redundancy involved in importing your package everywhere you want to use it.

The problem here is that they integrate into the HTTP module of angular to make this possible. For my idea, I was thinking you can find a way around it. Say something creative as any calls after a component is loaded or something else.

I am sure there is a way, think about it, If it's not possible then you would have tried.

hasante avatar May 29 '20 17:05 hasante

This is a specialization of a generic component IMHO. Since there are many 3rd party libraries for remote calls along the fairly new fetch, and in my case, I tend to use those 3rd party libraries still even when there's a native API in the standard, because, not all browsers still support it and using a polyfill is just the same as using a 3rd party lib without the extra oomph.

I think this is rather pointless in this state of browser market share, or at least as long as there are non deprecated browsers and browser versions that does not yet support native fetch API; especially in the enterprise environments.

khooz avatar Jun 07 '21 09:06 khooz