Giter Site home page Giter Site logo

Comments (3)

alexcorre avatar alexcorre commented on June 16, 2024

Also if you have any suggestions on where to start in a pull request for this let me know as I'd love to contribute back.

I started working here to dispatch_sync back to main queue there, but this breaks the unit tests as they execute this method directly on the main thread and thus dispatching sync would cause deadlock.

Also dispatch_async to main queue here breaks unit tests as it can't verify that that handler is invoked after data updates are flushed. See this test;

This was just a test attempt to see if I could make a quick fix. Ideally the queue on which to execute the block should be configurable, or default to the queue that called the method.

from meteor-ios.

alexcorre avatar alexcorre commented on June 16, 2024

Same goes for global NSNotifications that are exposed in METDDPClient

from meteor-ios.

martijnwalraven avatar martijnwalraven commented on June 16, 2024

I completely agree. In most cases, being called back on the main queue is what you want so this should be the default to avoid a common source of bugs. Ideally, the queue would indeed be configurable. As far as I know, there is no reliable way to default to the queue that called a method (dispatch_get_current_queue is deprecated). We could add a queue: argument to all methods that take a callback block and that defaults to the main queue (but that wouldn't work for notifications) or specify this at a more global level. A callbackQueue property on METDDPClient is probably sufficient for most uses (other name suggestions welcome).

I'd have to look more into this to be sure, but maybeInvokeCompletionHandler seems like the right place to dispatch to a different queue. That might require changes to the unit tests. In other places, I use XCTestExpectation/waitForExpectationsWithTimeout: to test async code. Here the issue seems to be that I wanted to test that the callback isn't invoked when only one of didReceiveResult:error and didFlushUpdates: is called. But I don't like the dependency on synchronous invocation and would prefer to find another way to test this.

If you have any ideas about this, please try them out and let me know or make a pull request. I probably won't have time to work on this myself before next week.

from meteor-ios.

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.