Giter Site home page Giter Site logo

Asynchronous Callback about just HOT 5 CLOSED

dduan avatar dduan commented on July 23, 2024
Asynchronous Callback

from just.

Comments (5)

JustHTTP avatar JustHTTP commented on July 23, 2024

Can you provide back trace? Pseudo code is not helpful since it's not crashing for anybody else.

Daniel Duan
Sent from my iPhone

On Sep 22, 2016, at 4:49 AM, aguel [email protected] wrote:

My app crashing using asynchronous callback but works fine when switching to synchronous mode. I dont know why.

Pseudo Sample:
APP CRASHING:
Just.post(
"http://justiceleauge.org/member/register",
data: ["username": "barryallen", "password":"ReverseF1ashSucks"],
files: ["profile_photo": .URL(fileURLWithPath:"flash.jpeg", nil)]
) { r in
if r.ok { /* SOME CODE HERE! */ }
}

THIS WORKS:
let r = Just.post(
"http://justiceleauge.org/member/register",
data: ["username": "barryallen", "password":"ReverseF1ashSucks"],
files: ["profile_photo": .URL(fileURLWithPath:"flash.jpeg", nil)]
)

if r.ok { /* SOME CODE HERE! */ }


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

from just.

svoip avatar svoip commented on July 23, 2024

NSURLSession has some asserts that if not respected by your code will yield crash. For example, use of asynchronous upload methods (with completion handler) in a background NSURLSession configuration.

from just.

aguel avatar aguel commented on July 23, 2024

Do you have any sample code? The documentation provides only simple example. Thanks.

from just.

sravanco avatar sravanco commented on July 23, 2024

I had a crash with asynchronous callback saying that Im updating UI in background thread. As in the Note given here, I have to dispatch UI update to main thread. Great if callback is already wrapped into main queue by JustHTTP.

DispatchQueue.main.async {
    //Update UI here.
}

from just.

JustHTTP avatar JustHTTP commented on July 23, 2024

Just can't wrap callback for you because lots of times that's not what user needs. You'll find after a networking call, there's more work to do (processing things you just downloaded, for example) before you need to update UI.

This is also the design decision made by Apple with NSURLSession.

Daniel Duan
Sent from my iPhone

On Sep 25, 2016, at 8:24 AM, sravanco [email protected] wrote:

I had a crash with asynchronous callback saying that Im updating UI in background thread. As in the Note given here, I have to dispatch UI update to main thread. Great if callback is already wrapped into main queue by JustHTTP.

DispatchQueue.main.async {
Update UI here.
}

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

from just.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.