JuliaGizmos / Blink.jl

Web-based GUIs for Julia
Other
360 stars 75 forks source link

Make all exported content apis synchronous (or provide done callback) #108

Open NHDaly opened 6 years ago

NHDaly commented 6 years ago

Hi! In line with #35, #41 and #56, can we make body! (and probably also content!, loadcss!, loadjs!, load!, importhtml!) synchronous?

It took me a while to track down why my app was sometimes crashing at the beginning, and it's because there's a race with loading javascript and reading it later with var = @js w varJS.

Can we just make all of those methods synchronous, following the same technique as in those other PRs? Thanks! :)

pfitzseb commented 6 years ago

Yeah, this seems like the right way forward. I'd heavily prefer having callbacks though.

NHDaly commented 6 years ago

Cool, I think so too!

Do any of the functions use "done" callbacks right now? It looks like the only thing I've seen is a synchronous option implemented with the javascript Promise api. To implement a done callback, would we just have the javascript trigger a julia callback function, rather than the Promise's resolve function?

NHDaly commented 6 years ago

Although actually for me personally, simply having a synchronous method is much simpler. As is, I just find myself putting sleep statements there anyway.

NHDaly commented 6 years ago

Hi! I know it's been literally half a year, but i'm still interested in having synchronous functions for Blink! :)

I'd heavily prefer having callbacks though.

I liked what Shashi said in this comment:

If you want something to be asynchronous you can always call it with @async.

- https://github.com/JunoLab/Blink.jl/issues/41#issuecomment-210856631

What do you think? I'll try to look into implementing this again in a day or two!