Comments (6)
HiI! Right now we only have "unauthorizedRequestCallback", it gets called when a 403 is triggered so you can renew your token.
https://github.com/3lvis/Networking/blob/master/Sources/Networking.swift#L169
I think we could do better, though. What are your thoughts on the current solution?
from networking.
🤔 Is it called for all requests? If so, In theory, you could put in a couple of NSLock
s and initiate retrials for all the requests after getting a new token, right?
from networking.
That could work 🤔.
I guess that's the biggest missing piece at the moment, the retrials after the token part. I guess ideally you have all the requests in a queue and if you get a 403, you stop all the requests in the queue until the token is renewed, then you restart the pending requests.
from networking.
all the requests in a queue
You mean in a concurrent queue, correct? Doesn't URLSession do that by default?
from networking.
We could probably use that one
https://developer.apple.com/documentation/foundation/urlsession/1411597-init
from networking.
@3lvis how about we have a post and a pre-response hook for all requests? That way, you don't execute a completion
block (like in https://github.com/3lvis/Networking/blob/master/Sources/Networking%2BHTTPRequests.swift#L13 )
until the post commit hook is completed. If you have a 401 with an expired token, execute a lock.lock*()
, and refresh your tokens. Once your token is refreshed, retry the request (not quite sure how you'd do that)
I've also been considering implementing this an Rx extension to Networking (imagine having a shared observable and every request using the retry
operator with it. It could also be used in conjunction with Rx's smart retry policies
from networking.
Related Issues (20)
- Support for JSONDecoder HOT 8
- Json parameters support on DELETE HOT 3
- Progress Multipart Upload HOT 2
- Support PATCH method HOT 1
- Network Activity Indicator not showing
- Change the base URL for a single request? HOT 1
- Installation Support Swift Package Manager HOT 2
- Caching folder should not be documents folder HOT 1
- fakeGET crashes under XCode 10.0 and Swift 4.2
- Expose handleJSONRequest(..)? HOT 3
- Problem with changes on UI Threath HOT 3
- `cacheOrPurgeData` causing production crashes HOT 3
- Can't use Swift 5 Result enum due to interference with custom one. Need to rename? HOT 3
- I didn't found way to get my body data as json parsing is failing HOT 7
- Facing a strange crash time to time HOT 3
- No waitsForConnectivity support for background request. HOT 1
- Using Networking lib to make a post in the background? HOT 3
- Question - Request caching HOT 2
- Troubleshooting Logging Errors in Xcode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from networking.