These are chat archives for opal/opal

23rd
Nov 2015
Jared White
@jaredcwhite
Nov 23 2015 04:24
@fazibear Wow, Awesome-Opal looks great! Thanks for putting that together
Mitch VanDuyn
@catmando
Nov 23 2015 19:59
@fkchang seems like require_js should return a promise?
Forrest Chang
@fkchang
Nov 23 2015 20:35
@catmando the current implementation adds the <script> element to the dom, if there's a way to know when that actually gets loaded by the browser and put a promise around that, I'm game, else you load it synchronously with require_js_sync*(
Mitch VanDuyn
@catmando
Nov 23 2015 20:36
doesn't jquery have all this stuff? Or are you trying not to depend on jquery?
Mitch VanDuyn
@catmando
Nov 23 2015 21:04
I just tried using
`jQuery.getScript("https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js",function(a, b) {alert('hi '+b)})`
in opal-irb, and it worked... i had previously tried getScript on a github raw js file, and getScript did not work... so it may not be as robust as require_js, but...
meh.
@meh
Nov 23 2015 21:22
it probably checks the Content-Type
Mitch VanDuyn
@catmando
Nov 23 2015 21:24
it does
Forrest Chang
@fkchang
Nov 23 2015 21:38
@catmando I am trying to get rid of jquery, but I might give up on that
Mitch VanDuyn
@catmando
Nov 23 2015 21:39
well you could just see how they do it? the advantage would be you could make yours less restrictive... as noted theirs seems to check the content-type, which I think should at least be an option.
fyi.. can you have an onload call back on a script tag??? I will try that in a second
meh.
@meh
Nov 23 2015 21:40
catmando, I'm pretty sure you can
Mitch VanDuyn
@catmando
Nov 23 2015 22:12
seems to work great... @fkchang you can just add a call back / promise into your require_js handler... I will do a pull request okay?
Mitch VanDuyn
@catmando
Nov 23 2015 22:18
well its a nice theory, but it then makes the code pretty ugly - you would have to nest everything inside of the dependent require, or you could set some global react state (if using react.rb)...