These are chat archives for opal/opal

21st
Aug 2015
meh.
@meh
Aug 21 2015 00:08
I hate you travis
Mitch VanDuyn
@catmando
Aug 21 2015 00:09

I am getting this error:

gems/sprockets-3.3.2/lib/sprockets/resolve.rb:64:in `resolve!': couldn't find file 'opal-react' with type 'application/javascript' (Sprockets::FileNotFound)
    from /Users/mitch/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.2/lib/sprockets/context.rb:88:in `resolve'
    from /Users/mitch/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.2/lib/sprockets/legacy.rb:259:in `resolve_with_compat'
    from /Users/mitch/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.2/lib/sprockets/context.rb:142:in `require_asset'
    from /Users/mitch/.rvm/gems/ruby-2.2.2/gems/opal-0.8.0/lib/opal/sprockets/processor.rb:68:in `block in process_requires'
    from /Users/mitch/.rvm/gems/ruby-2.2.2/gems/opal-0.8.0/lib/opal/sprockets/processor.rb:66:in `each'
    from /Users/mitch/.rvm/gems/ruby-2.2.2/gems/opal-0.8.0/lib/opal/sprockets/processor.rb:66:in `process_requires'
    from /Users/mitch/.rvm/gems/ruby-2.2.2/gems/opal-0.8.0/lib/opal/sprockets/processor.rb:45:in `evaluate'

The only problem is there is no opal-react anywhere. Not in the rails app, no in any of the gems. I did a text search and its just does not exist.

I WAS referencing the gem, but removed it.

I have tried doing an rm -rf tmp/cache

I have blown away Gemfile.lock and reloaded.

Any other ideas?

meh.
@meh
Aug 21 2015 00:11
maybe something cached by sprockets?
or was that tmp/cache?
try a bundle install --path foo
Mitch VanDuyn
@catmando
Aug 21 2015 00:41
@meh found it... it was my textmate being goofy... for whatever reason it missed two files, but when I just did a grep they were there!
meh.
@meh
Aug 21 2015 00:41
heh
Can Edremitoglu
@cantonic
Aug 21 2015 09:01
hey guys. Can somebody tell me what the opal-jquery equivalent of $(document).ajaxStart() is?
Martin Becker
@Thermatix
Aug 21 2015 09:09
I don't know about that but you can use HTTP.post or HTTP.get
Martin Becker
@Thermatix
Aug 21 2015 09:53
whats the class type of {}?
wait, nvm
Forrest Chang
@fkchang
Aug 21 2015 19:46
@all what are the general 0.8 upgrade tips?
@elia seeing Sprockets::FileNotFound - couldn't find file 'boolean_editor.html' with type 'application/javascript': for the opal haml templates that worked fine on 0.7 in 0.8 for opal and opal-rails
Elia Schito
@elia
Aug 21 2015 19:48
If using sprockets and not opal-Rails you need to manually bootstrap the app with Opal.load("application")
@fkchang ^
Here's an helper that does just that taking care of everything http://opal.github.io/docs/v0.8.0/lib/classes/Opal/Processor.html#method-c-load_asset_code
Forrest Chang
@fkchang
Aug 21 2015 19:53
@elia so in an opal-rails app, what do we need to do?
is a cache clear needed? I backed off to 0.7 and I had to do that to get it to work
Forrest Chang
@fkchang
Aug 21 2015 20:00
oh, but it it didn't work, I'll try again after lunch
Mitch VanDuyn
@catmando
Aug 21 2015 20:05

is it possible to load a js file from within an Opal gems main file?
For example I have

#my_fat_gem.rb
if RUBY_ENGINE == 'opal'
  require 'foo'
  require 'react.js'
...
else
...
end

everything works, but unless I require react out in the application.rb it doesn't seem to load...

I think the problem is something to do with the way opal require actually works... For prerendering to work I need that 'react.js' file to be loaded just like a normal js asset file? Is that possible?

Ryan Stout
@ryanstout
Aug 21 2015 20:35
@elia you around by chance?
Elia Schito
@elia
Aug 21 2015 20:44
@ryanstout kinda, but I'll try to reply
Ryan Stout
@ryanstout
Aug 21 2015 20:44
@elia actually, I figured out a solution.
thanks
Adam Jahn
@ajjahn
Aug 21 2015 21:51
@elia or @meh (or anyone else) -- Can you offer any insight on using Browser::Event in opal-browser? Basically, I want to add a 'progress' event listener to a Browser::HTTP::Request (XMLHttpRequest) object. Maybe I'm not even barking up the right tree.
meh.
@meh
Aug 21 2015 21:51
ajjahn, I don't even know how that's done in JS :D
Adam Jahn
@ajjahn
Aug 21 2015 21:52
$.ajax({
  xhr: function()
  {
    var xhr = new window.XMLHttpRequest();
    //Upload progress
    xhr.upload.addEventListener("progress", function(evt){
      if (evt.lengthComputable) {
        var percentComplete = evt.loaded / evt.total;
        //Do something with upload progress
        console.log(percentComplete);
      }
    }, false);
    //Download progress
    xhr.addEventListener("progress", function(evt){
      if (evt.lengthComputable) {
        var percentComplete = evt.loaded / evt.total;
        //Do something with download progress
        console.log(percentComplete);
      }
    }, false);
    return xhr;
  },
  type: 'POST',
  url: "/",
  data: {},
  success: function(data){
    //Do something success-ish
  }
});
Something like that I suppose.
meh.
@meh
Aug 21 2015 21:53
what is xhr.upload?
ah, it's a field
ajjahn, yeah, the upload part isn't done yet, I didn't even know it existed
and I can't do anything until sunday 5 pm, or when I'm done getting to 400 achievements points in D3 season, it's very important :P
Adam Jahn
@ajjahn
Aug 21 2015 21:54
I don't need the upload part at this point, I haven't worked out how to hook into the download progress.
meh.
@meh
Aug 21 2015 21:54
then just pass a block to the HTTP.post
then use #on :progress
Adam Jahn
@ajjahn
Aug 21 2015 21:56
I tried that with no luck. As far as I can tell browsing the source, progress isn't one of the callbacks being listened for.
meh.
@meh
Aug 21 2015 21:56
isn't it just a dom event?
ah I see it
meh.
@meh
Aug 21 2015 22:00
right, gimme a sec
Adam Jahn
@ajjahn
Aug 21 2015 22:00
Thanks. Yeah so no luck with the Request object led me here: https://github.com/opal/opal-browser/blob/master/opal/browser/event/progress.rb , but like I said, no idea if I'm on the right track.
meh.
@meh
Aug 21 2015 22:01
you are, kind of
meh.
@meh
Aug 21 2015 22:08
ajjahn, can you test the progress branch please?
Adam Jahn
@ajjahn
Aug 21 2015 22:11
Yes...
meh.
@meh
Aug 21 2015 22:12
@elia when you have time can you update opal-browser to the latest rspec/opal?
getting some errors I have no clue about
Adam Jahn
@ajjahn
Aug 21 2015 22:18
Works!
Adam Jahn
@ajjahn
Aug 21 2015 22:24
Except, now the other events (i.e. here: https://github.com/opal/opal-browser/blob/master/opal/browser/http/request.rb#L317) aren't firing. Not even 'complete'.
meh.
@meh
Aug 21 2015 22:26
weird
ah found the problem
Adam Jahn
@ajjahn
Aug 21 2015 22:28
The good news is I see what's going on with Event now.
meh.
@meh
Aug 21 2015 22:29
no wait I don't
no wait I do
ffff
stupid Ruby
no wait I don't :D
ajjahn, it must be a weird interaction between Event::Target and Request
like a method collision or something
or super not working properly
which I seriously hope isn't the case
Adam Jahn
@ajjahn
Aug 21 2015 22:41
Hmm, I'll keep tinkering...