Skip to content

DispatchQueue.main.sync slightly delays showing initial loading view #47

Closed

Description

@FWJonathan

If already on the main thread, the call to DispatchQueue.main.sync in transitionToState(...) will delay a loading view presentation briefly so that the main view is shown before valid data is present.

This could be resolved with something like the following logic:

if Thread.isMainThread {
      ...
} else {
   DispatchQueue.main.sync() {
      ...
   }
}

Activity

  1. FWJonathan commented on Feb 10, 2017

    @FWJonathan
    Author

    On further observation I see that this isn't quite so simple as the call happens within an async block in the local queue. The only way I see to workaround this currently is to hide the viewController's view until loading completes, or am I missing something?

  2. aschuch commented on May 15, 2017

    @aschuch
    Owner

    Yes you are right, I am usually calling startLoading() from viewWillAppear as shown in the example project. Do you still see this behaviour when used from viewWillAppear?

  3. FWJonathan commented on May 18, 2017

    @FWJonathan
    Author

    Hmm, I was seeing this behaviour when I posted, but I've made several changes to my loading flow since adding a workaround, and after removing the workaround it now seems ok!

    It could be that my call to startLoading() itself may have been getting pushed back a cycle, but I can't verify this now. Let's assume that it's ok for now and I'll let you know if it re-occurs. Anyway, thanks for the library, very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions