Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
FWJonathan opened this issue Feb 10, 2017 · 3 comments
Closed

Comments

@FWJonathan
Copy link

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() {
      ...
   }
}
@FWJonathan
Copy link
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?

@aschuch
Copy link
Owner

aschuch commented May 15, 2017

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?

@FWJonathan
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants