Comments (5)
Hi @alperkal, thanks!
Let's see, does the progress view update if you set it on a timer? Something like this
var percent: Double = 0
let timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
print(count)
self.progressView.setProgress(percent, animated: false)
count += 0.1
}
from just.
yes, progressView does update when triggered via a timer:
var count = 0.0
_ = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
print(count)
self.progressView.setProgress(Float(count), animated: false)
count += 0.1
}
from just.
BTW, I haven't extracted the code from an existing big project. That was the most basic view Controller running in a clean project.
import UIKit
import Just
class ViewController: UIViewController {
@IBOutlet weak var progressView: UIProgressView!
@IBOutlet weak var button: UIButton!
@IBAction func buttonClicked(_ sender: AnyObject) {
let sampleFile = Bundle.main.url(forResource: "sample", withExtension: "jpg")!
Just.post("https://httpbin.org/post",
files:["sample": .url(sampleFile, nil)],
asyncProgressHandler:{ p in
print(p.percent)
DispatchQueue.main.async(execute: {
self.progressView.setProgress(p.percent, animated: false)
})
})
print("Complete!!")
}
}
from just.
ok, I got it working finally. I don't know why it only works like this:
Just.post("https://httpbin.org/post",
files:["sample": .url(sampleFile, nil)],
asyncProgressHandler:{ p in
print(p.percent)
DispatchQueue.main.async(execute: {
self.progressView.setProgress(p.percent, animated: false)
})
}){ r in
print(r.ok)
}
Looks like UI gets updates only if the call is issued asychronously
from just.
When Just work synchronously, it needs to block on current thread. If it blocks on the main thread, then any other operation dispatched onto the main thread won't execute until the network is finished. The print statement works because it's not on main thread.
from just.
Related Issues (20)
- Authentication is not happening in swift 4 HOT 1
- Playground Execution Failed
- POST is returning nil response in Swift 4
- How to use Just in multipart?
- Just is giving code -1001 HOT 1
- Multiple Image
- Can Just Support proxying HTTP requests? HOT 1
- Just.get params always return string Optional HOT 1
- Just.framework missing CFBundleVersion when uploading HOT 7
- Not available like pod
- Multiple endpoints
- How can I send a single string parameter?
- Not building in Xcode to run on device
- Does Just follow redirect links?
- Just.get() crash when `makeTask` HOT 2
- It seems like `asyncCompletionHandler` is executed before download task is done HOT 1
- [Suggestion] Completion handler should be call on Main Thread
- Utilizing r.json response? HOT 2
- Just Library is not supported for Xcode 12 and above HOT 1
- How to Download file HOT 2
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 just.