These are chat archives for opal/opal

26th
Jun 2015
Vais Salikhov
@vais
Jun 26 2015 01:58
@ryanstout the relationship between date, time, datetime, etc. in Ruby always confused the heck out of me. That's why I'm working on implementing these things in Opal now, hoping to figure it out once and for all, but it's been a slog :sweat_smile:
Ryan Stout
@ryanstout
Jun 26 2015 02:00
@vais yea, I think there's one (or probably two) too many date/time classes in ruby :-)
@vais thanks for the hard work, let me know if there's something I can help with.
Vais Salikhov
@vais
Jun 26 2015 02:06
Thanks @ryanstout. Right now, if you require 'time', you can do Time.parse, which simply calls Date.parse, whose implementation is just two lines of code that uses this regex: /^(\d*)-(\d*)-(\d*)/. Leaves much to be desired to say the least. You may not want to lean too heavily on it at this time.
Ryan Stout
@ryanstout
Jun 26 2015 02:14
@vais no worries. Yea, I figured too you probably don't want all of the parse logic in corelib because its probably huge (file size wise :-)
George Plymale II
@ylluminarious
Jun 26 2015 02:30
some weird problems with native inheritance: http://cl.ly/400W070w1z2F
@elia @meh @adambeynon got any suggestions / input?
Vais Salikhov
@vais
Jun 26 2015 02:31
@ryanstout right, but it wouldn't go into corelib's Time, it would go into stdlib Date or Time, which you'd then require if you need it, so file size should not be an issue.
Ryan Stout
@ryanstout
Jun 26 2015 02:31
cool
Forrest Chang
@fkchang
Jun 26 2015 16:09
@ylluminarious in 'toll free bridging' you need to redefine Klass.new because the original javascript constructor maps to Ruby's allocate (http://seejohncode.com/2012/03/16/ruby-class-allocate/)
Nathan Hopkins
@hopsoft
Jun 26 2015 17:55
Is it possible to use opal + react-rails + react.rb? I keep getting parse error on value "Unobtrusive" (tCONSTANT) :react_ujs:3 when the pipeline tries to load react_ujs.js.erb. Is opal is attempting to process this file because it's erb?
Here is the start of the file it dies on:
/*globals React, Turbolinks*/

// Unobtrusive scripting adapter for React
;(function(document, window) {
  // jQuery is optional. Use it to support legacy browsers.
  var $ = (typeof window.jQuery !== 'undefined') && window.jQuery;
Mitch VanDuyn
@catmando
Jun 26 2015 18:36
@hopsoft - We have been using opal + react-rails + react.rb. I don't remember ever seeing that problem (but I saw so many :-)... I could get together with you and try to figure this out. Let me know
Nathan Hopkins
@hopsoft
Jun 26 2015 18:38
@catmando now that you have some battle scars, would you choose this path again?
Mitch VanDuyn
@catmando
Jun 26 2015 18:38
Experts! I have a loading twist here I just can't work out:
I have opal running on the server (in rubyracer under react-rails) + ruby code on server + opal in browser.
The problem I just ran into is need opal-jquery on the browser, but not (obviously) on the opal server side.
This is all going into a gem, so its a bit unclear how I can require opal-jquery only if the browser is loading
@hopsoft - I am betting my whole company on it :-)
Nathan Hopkins
@hopsoft
Jun 26 2015 18:40
@catmando Thanks. I'll reach out to you in a bit if I can't get past it.
Mitch VanDuyn
@catmando
Jun 26 2015 18:40
@hopsoft - but we not using JSX at all. Its pure ruby, with a highly modified version of react.rb. My developers are really loving it.
@hopsoft - yeah just ping me. I'll try to keep one eye on gitter
Mitch VanDuyn
@catmando
Jun 26 2015 19:01
regarding my request for conditionally loading: I just did this which seems to work:
ruby if RUBY_ENGINE == 'opal' if `typeof window.ReactiveRecordCache == 'undefined'` require 'opal-jquery' end end where window.ReactiveRecordCache is a variable defined only if running opal on the server
This works, but I was SURE that i saw warnings when I was getting the AASM gem working whenever that gem did conditional requires.
Elia Schito
@elia
Jun 26 2015 21:27
@catmando that's the way to go
Elia Schito
@elia
Jun 26 2015 21:52
warnings are printed for dynamic requires, which can't be clearly inferred by the compiler