These are chat archives for opal/opal

10th
Dec 2015
meh.
@meh
Dec 10 2015 00:01
@elia I'm not sure I follow
@elia I'm a little drunk, talk simple :D
Elia Schito
@elia
Dec 10 2015 00:01
LOL
Brady Wied
@wied03
Dec 10 2015 00:04
BasicObject__beer(){};
Elia Schito
@elia
Dec 10 2015 00:04
was thinking about renaming function BasicObject(){} to function BasicObject_alloc(){}
(https://github.com/opal/opal/blob/master/opal/corelib/runtime.js#L22)
@wied03 :beers:
:D
That's because that JS constructor will serve BasicObject#alloc while Opal.BasicObject will contain this: https://github.com/opal/opal/blob/master/opal/corelib/runtime.js#L10
meh.
@meh
Dec 10 2015 00:06
ah
yeah, I'm fine with that
Elia Schito
@elia
Dec 10 2015 00:07
the only downside is that stack traces in the browser will show BasicObject instances as BasicObject_alloc objects
Martin Becker
@Thermatix
Dec 10 2015 01:09
but if I don't then it complains that DOM doesn't exist...
and I'm properly requiring browser
Martin Becker
@Thermatix
Dec 10 2015 01:14
YES! it works!
well... sort of, but it's closer!
any way, g'night!
Elia Schito
@elia
Dec 10 2015 01:23
@/all btw opal recently passed 3k stars on GH :star2: :tada:
Mitch VanDuyn
@catmando
Dec 10 2015 01:28
:clap:
LeoDaoTao
@LeoDaoTao
Dec 10 2015 04:11

Howdy, I’m trying to use Opal with Rails and I get this error

Bad new_assignable type: self

It points to my application.html.erb

javascript_include_tag 'application', 'data-turbolinks-track' => true

How do I even start troubleshooting this?

Mitch VanDuyn
@catmando
Dec 10 2015 05:15
is new_assignable in your code someplace? If so can you show that line, and those around it please?
LeoDaoTao
@LeoDaoTao
Dec 10 2015 05:19
nope, just crated the manifest file, it’s a clean rails install
Mitch VanDuyn
@catmando
Dec 10 2015 05:21
so the other day you also created a clean rails install, etc, right? (To create your react.rb test) so what is different?
LeoDaoTao
@LeoDaoTao
Dec 10 2015 05:21

application.js.rb

require 'jquery'  
require 'jquery_ujs'  
require 'opal'  
require 'opal_ujs'  
require 'front’

Added front to app dir
Have front.js.rb in front dir:

if RUBY_ENGINE == 'opal'  
  require_tree '.'
end

That’s all I have

@catmando it was a clean rails install as well. I do not see what is different all that much.
don’t a have a good understanding how opal works within rails and that makes it harder for me to see where the problems could be, need to go through some errors and it will be easier I suppose :-)
Mitch VanDuyn
@catmando
Dec 10 2015 05:25
hmmm... what version of opal gem do you have? I think reactive-ruby locks it at an earlier version. I'll bet you are on 0.9 something...
LeoDaoTao
@LeoDaoTao
Dec 10 2015 05:28
hmm, it was 0.9 something earlier today, now it’s 0.8.1 after bundle update I did earier, but still getting the same error
LeoDaoTao
@LeoDaoTao
Dec 10 2015 05:33
nope, correction it was 0.8.1 since the begining, not sure were I saw 0.9
Alex Dowad
@alexdowad
Dec 10 2015 05:37
@LeoDaoTao 1) Opening a GH issue would be good 2) You said that you "get" an error. What do you do to "get" the error? Start your Rails app? 3) Can you get a stack trace?
LeoDaoTao
@LeoDaoTao
Dec 10 2015 05:38
I think I’m getting at it, I removed a reference to my front dir in the application.js.rb manifest so the problem is with my setup, investigating further
LeoDaoTao
@LeoDaoTao
Dec 10 2015 05:50
OK solved it. I named my file hello.opal.rb and that has caused the Bad new_assignable type: self error, I renamed it to hello.js.rband all is good
Alex Dowad
@alexdowad
Dec 10 2015 05:58
Good to hear :smile:
Elia Schito
@elia
Dec 10 2015 08:59
@LeoDaoTao it was trying to compile twice, compiled js assigns "this" to the var "self", but "self = foo" is invalid in ruby. Thus the error. :)
(it's just for the record, not actually important)
Alex Dowad
@alexdowad
Dec 10 2015 13:29
Question: has any work been done on implementing the new keyword arguments? Any thoughts on best translation into JS?
Elia Schito
@elia
Dec 10 2015 13:31
kwargs are supported to some extent, but for example I think splat support is missing
@alexdowad are you referring to something in particular?
Alex Dowad
@alexdowad
Dec 10 2015 13:33
Looking at how to implement kwargs for blocks: { |**kws| ... } and so forth
Elia Schito
@elia
Dec 10 2015 13:34
no work has been done, but would be happy to start a branch/PR for that, as you know we were kinda stuck on the parser side :)
Alex Dowad
@alexdowad
Dec 10 2015 13:34
Parser is now unstuck. The compiler is catching up
Elia Schito
@elia
Dec 10 2015 13:35
indeed :sparkles:
so, my idea for that is to start working on it but wait to merge until 0.9 is released, for which I think the time has come, the only PR I need to merge before that is #1232
Alex Dowad
@alexdowad
Dec 10 2015 13:37
OK. I won't push anything to master right now then
Elia Schito
@elia
Dec 10 2015 13:38
I usually push to elia/* and then do a PR to track changes and allow others to review/discuss. But still consider branches starting with "elia" a place where I can push -f
usually after rebasing on origin/master
Martin Becker
@Thermatix
Dec 10 2015 13:40
my router is now capable of rendering contexts, components and sub contexts and their components :D
Elia Schito
@elia
Dec 10 2015 13:43
@alexdowad the whole explanation was just a way to say: please push (to a branch) because I'd love to follow along with changes :)
Alex Dowad
@alexdowad
Dec 10 2015 13:44
OK, just pushed an 'alex' branch which is my current 'dev' branch
Elia Schito
@elia
Dec 10 2015 13:44
:+1:
Alex Dowad
@alexdowad
Dec 10 2015 13:45
Quick way to initialize an empty Hash from JS-land?
An Opal Hash, not an empty JS object
Looks like $hash2([], {})
Elia Schito
@elia
Dec 10 2015 13:59
Opal.hash
should be able to take an empty js object
IIRC
Karim Tarek
@karimmtarek
Dec 10 2015 14:26
@elia for someone new to Ruby and doesn’t have much experiance with JS how can I help with the project?
Mitch VanDuyn
@catmando
Dec 10 2015 14:30
@karimmtarek - come on over to https://gitter.im/zetachang/react.rb we need help with newbies to try things out and help to make sure documentation works, create examples - (that is the opal core guys don't put you to work :-)
Karim Tarek
@karimmtarek
Dec 10 2015 14:31
@catmando sounds good to me I’m heading there right now :D
Elia Schito
@elia
Dec 10 2015 14:40
@catmando help stealer! 😸
Mitch VanDuyn
@catmando
Dec 10 2015 14:41
@elia - what can I say?? I'm sure you can give him plenty of challenges too!
Elia Schito
@elia
Dec 10 2015 14:42
:D
@karimmtarek we need docs and reviews of all things written, especially from the point of view of someone new that can still notice stuff we're used to
@karimmtarek a good start would be pointing out stuff that's not clear on opalrb.org
Martin Becker
@Thermatix
Dec 10 2015 14:45
question, why is opal-browser's history push function set up like this:
def push(item, data = nil)
    data = `null` if data.nil?

    `#@native.pushState(data, null, item)`
  end
because I can't set a page name
Elia Schito
@elia
Dec 10 2015 14:47
cc @meh ^
Karim Tarek
@karimmtarek
Dec 10 2015 14:50
@elia sure thing, if found anything how should I pointed it out?
Mitch VanDuyn
@catmando
Dec 10 2015 14:52
@elia - HEY...
Martin Becker
@Thermatix
Dec 10 2015 15:00
also the history module is failing, for some reason self["native"] is undefined
George Plymale II
@ylluminarious
Dec 10 2015 15:51
@elia re: 3k stars, :clap: :tada:
Martin Becker
@Thermatix
Dec 10 2015 16:29
@all need an angle on a problem,
ok soo
all routes are mounted under a context, but routes can be mounted under a sub context as well
the router keeps track of the context the person user is currently in, but only the root, context, not any sub_context
a context is a screen composition of components, handlers for each component and attending routes
a sub_context is a context mounted under another context similar to a partial template being rendered in another template
the problem
is that when a user clicks a button
and you use the navigate_to function, how do I work out if the button clicked on is inside a sub-context and therefore should map to a sub-context route?
Martin Becker
@Thermatix
Dec 10 2015 16:44
I guess what I need is to store the context at time of rendering then work out how to attach it and then reference it when I need it
I guess I can attach it to the component anchor elements
then...find the nearest anchor element when the button is clicked on to find the context
Martin Becker
@Thermatix
Dec 10 2015 19:15
solved it by creating a function that returns a proc that executes with the correct values!
Mitch VanDuyn
@catmando
Dec 10 2015 19:57
Browser Web Sockets? working in opal 0.8? Tried to access using @fkchang 's opal playground but its not there
Martin Becker
@Thermatix
Dec 10 2015 20:14
@catmando I'm not too far from finishing, soon we'll have an opal only router
Mitch VanDuyn
@catmando
Dec 10 2015 20:15
excellent!
Martin Becker
@Thermatix
Dec 10 2015 20:16
it treats components as first class citizens,
and it's frame-work agnostic
Mitch VanDuyn
@catmando
Dec 10 2015 20:36
@ws = Browser::Socket.new("wss://ruby-websockets-chat.herokuapp.com/") do |s|
...
end
complains that "wss://ruby-websockets-chat.herokuapp.com/"; is not native?!?!
Forrest Chang
@fkchang
Dec 10 2015 20:48
@catmando browser/socket is not required in opal-playground or opal-irb apps, I can
Mitch VanDuyn
@catmando
Dec 10 2015 20:52
@fkchang - okay... I am having trouble getting it working...lets see what I hit.. will let you know.
Mitch VanDuyn
@catmando
Dec 10 2015 21:05
@fkchang okay it works, but I had to require 'browser' then require 'browser/socket'