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

[READY] Added an optional callback function to hs.image.imageFromURL #2227

Conversation

latenitefilms
Copy link
Contributor

@cmsj
Copy link
Member

cmsj commented Nov 1, 2019

So, this is technically still blocking, because although it's using dispatch_async(), it's specifying the main queue. I'll rewrite it shortly to do the image fetching on a background thread so it doesn't block the main thread at all.

@latenitefilms
Copy link
Contributor Author

@cmsj - Ah, interesting! I copied the code from hs.application:getMenuItems(), does that mean that code is also blocking, or am I misunderstanding something?

@cmsj
Copy link
Member

cmsj commented Nov 1, 2019

@latenitefilms nope, that code is also blocking, but that code has to run on the main thread because it touches the UI 🙂

dispatch_async() on the main thread is very useful for deferring work until the main thread is next idle, but we should only do it where we have to. For anything that can go on a background thread, it's usually better to do so.

I'm just updating Xcode to 11.2 and then I'll get a commit up :)

@latenitefilms
Copy link
Contributor Author

Awesome - thanks for the explanation @cmsj !

@cmsj
Copy link
Member

cmsj commented Nov 1, 2019

Closing in favour of 74ddcea

@cmsj cmsj closed this Nov 1, 2019
@latenitefilms latenitefilms deleted the issue-2224-imagefromurl-callback branch November 1, 2019 12:45
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

Successfully merging this pull request may close these issues.

Add a non-blocking variant of hs.image.imageFromURL
2 participants