These are chat archives for opal/opal

30th
Nov 2015
Martin Becker
@Thermatix
Nov 30 2015 17:23
I have a question that's partially related to opal,
I'm building a main routing app in padrino that will have sub apps mounted into it
how do I handle sprockets in this case?
Mitch VanDuyn
@catmando
Nov 30 2015 17:51
@/all what would be the best way to extend the Element class? The reason its tough is
a) I don't want to reference jQuery from the gem (react.rb) so I can't count on Element being defined
b) Element's base class is itself conditional

So I am currently doing this:

Element.class_eval do
   # add some new features to Element
end if Object.const_defined?("Element")

but this requires that jQuery be referenced before react.rb for things to work... Is there a better way?

Elia Schito
@elia
Nov 30 2015 17:54
slight improvement could be to keep the extension in a different file so you can require it also afterwards
Mitch VanDuyn
@catmando
Nov 30 2015 18:00
hmmm.... could I conditionally require opal-jquery? as in something like this:
begin
  require 'opal-jquery' 
  Element.class_eval do
   ....
  end
rescue ...
end
meh.
@meh
Nov 30 2015 18:00
catmando, nope, no dynamic requires
catmando, what do you need to do?
Mitch VanDuyn
@catmando
Nov 30 2015 18:01
@meh see question about 10 minutes ago... regarding extending Element (but only if Element is available)
meh.
@meh
Nov 30 2015 18:01
catmando, ok, let me open a browser
Martin Becker
@Thermatix
Nov 30 2015 18:03
Why not just have an if block that checks if Element have been defined? like you already had?
meh.
@meh
Nov 30 2015 18:05
catmando, personally I'd go like elia said
have something like a require 'react/jquery' or whatever
Martin Becker
@Thermatix
Nov 30 2015 18:08
btw, I realllllly think we should encourage opal-browser over jquery
they seem to do the same thing
but opal-browser does more +
meh.
@meh
Nov 30 2015 18:08
I really need to make opal-browser more cherry-pickable
Martin Becker
@Thermatix
Nov 30 2015 18:08
it's less abstracted
and less code will get loaded
since opal jquery needs opal-jquery & jquery to be loaded
opal-browser is just opal-browser
I don't see the need for opal-jquery over opal-browser
Elia Schito
@elia
Nov 30 2015 18:13
@meh re opal-browser vs. opal-jquery I'd like to remove the non-jquery stuff from opal-query and make browser a dep of opal-jquery
Mitch VanDuyn
@catmando
Nov 30 2015 18:18
thanks for the input... I think its easier for the user to simply say if you want to use react.rb with jquery jquery should be required first, instead of saying if you want to use react.rb with jquery, you add this other line that does xyzzy
Martin Becker
@Thermatix
Nov 30 2015 19:03
@elia I don't see the point since opal-browser does everything opal-jquery does (if I'm wrong, please correct me) and more
meh.
@meh
Nov 30 2015 19:31
Thermatix, if opal-browser doesn't do something jquery does, it's a bug, so open an issue :)
Martin Becker
@Thermatix
Nov 30 2015 19:36
lol I just mean since opal-browser does everything jquery does and more, whats the point of opal-jquery?
opal-browser is a wrapper around native browser functions
where as opal-jquery is a wrapper around jquery which itself is a wrapper around native browser functions (with a little extra)
using opal-jquery just introduces another layer for no gain
that I can see
meh.
@meh
Nov 30 2015 19:38
Thermatix, opal-jquery was born to ease introducing Opal into pre-existing applications
that already dependend on jquery
we just sucked at pushing opal-browser for new projects
Martin Becker
@Thermatix
Nov 30 2015 19:38
AH now that makes a bit more sense... kind of
what do you mean sucked?
meh.
@meh
Nov 30 2015 19:39
we never properly publicized opal-browser as the way-to-go for new projects
and since everyone knows about jquery they found opal-jquery
Martin Becker
@Thermatix
Nov 30 2015 19:45
AH, gotcha, yeah that makes sense, almost every one knows jquery so i guess it's the standard goto
Michał Kalbarczyk
@fazibear
Nov 30 2015 19:54
Hi, what about closing popups with opal-browser. Is broken now. Why close method looks so weird ?
meh.
@meh
Nov 30 2015 19:56
fazibear, ah yeah, I forgot to merge that
fazibear, honestly I don't remember why I did it like that
Michał Kalbarczyk
@fazibear
Nov 30 2015 20:07
@meh thanks!
@meh BTW a lot of changes has made since opal-browser was released. Is there any plans to release next version ?
meh.
@meh
Nov 30 2015 20:11
fazibear, I'll release a new version when I make it more cherry-pickable
Michał Kalbarczyk
@fazibear
Nov 30 2015 20:14
@meh good point, i wish to not require paggio just to make $document['']
is there any estimates for new release ?
meh.
@meh
Nov 30 2015 20:33
fazibear, soon™
CJ Lazell
@cj
Nov 30 2015 22:05
This message was deleted
Forrest Chang
@fkchang
Nov 30 2015 23:02
@cj it works, but you need to require 'date' first, since I do in opal-irb it works http://fkchang.github.io/opal-irb/index-jq.html#code:Date.today
Mitch VanDuyn
@catmando
Nov 30 2015 23:46
every(1) { ... } returns an Interval object but with the timer id set to nil, (so it can't be stopped)... anybody understand why?
meh.
@meh
Nov 30 2015 23:47
catmando, really?
catmando, are you sure you're not checking it AFTER it's stopped?
because it unsets the id after you call #stop or #abort