Code Monkey home page Code Monkey logo

Comments (3)

cocojoe avatar cocojoe commented on August 16, 2024

What is your actual issue? That you want to update Ux on the main thread? In that case you should call the main thread inside your closure and this is your responsibility. If you want to see this in action, please take a look at the samples:

https://github.com/auth0-samples/auth0-ios-swift-sample

from auth0.swift.

SeanLintern avatar SeanLintern commented on August 16, 2024

No, I think you misunderstand, I am saying that if a method goes to the background thread it should either state it in its docs or bring you back to the main thread when it is done internally, I don't think the user should have to guess the thread the callback will be on?

from auth0.swift.

cocojoe avatar cocojoe commented on August 16, 2024

Network requests should be handled async as they should never block the main thread. Have a look at URLSession which is what our network layer uses. You will see the completion handler (callback) is scheduled on the delegate queue. So this is standard and expected behaviour, no need for us to document this.

In a callback the developer should only switch to the main thread when it is necessary to do so, typically Ux changes. Otherwise they run the risk of unnecessarily blocking the main thread, which goes against best practice.

from auth0.swift.

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.