Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Elia Schito
@elia
right now I'm experimenting with uglily to see how it would handle it
Julian Scheid
@jscheid
okie dokie
I gotta run but I'll pop back in tomorrow after doing some experiments with mid_to_jsid
but just to whet your appetite...
the lib I'm compiling with opal ends up as a 2 MB JS file
uglify gets it down to 1.6 MB
closure compiler down to 1 MB ... and that's without any DCE
maybe I'll have some performance benchmarks tomorrow as well
:wave:
Elia Schito
@elia
πŸ‘πŸ‘πŸ‘ great stuff, see ya
Barrie Hadfield
@barriehadfield
@jscheid @elia :clap: :thumbsup:
Bernhard Weichel
@bwl21

Hi I need an advice: I initialize the contoller of my app with

Document.ready.then do |ready|
  uicontroller = Controller.new
  %x{
     window.zupfnoter=#{uicontroller};
  }
end

In order to have a global access to the Controller -instance I assign it to window.zupfnoter. The Controller produces SVG code in a worker which returns the SVG as a string. I would like to declare handlers in this string. I figured out the JS source code requird in the SVG code to access a method of an object stored in an instance variable of my controller:

      onclick = %Q{onclick="zupfnoter.tune_preview_printer.$_clickabcnote(evt, '#{id}')"}
      %x{
          #{@root}.out_svg('<rect ' + #{onclick}' ...);

which eventually produces

<rect onclick="zupfnoter.tune_preview_printer.$_clickabcnote(evt, '_note_436_438_')"></rect>

even if if works, I am not sure if this is the most elegant and robust approach:

  1. It depends on the global variable (zupfnoter). I would prefer to access the instance of the controller via something like Opal.top.uicontrollersuch that I do not need the global variable.

  2. It depends on the internals of the opal compiler. I would like to get the javascript name of the handler without knowledge of the internals how Ruby code is converted to javascript.

it should be something like

 onclick = %Q{onclick="#{JS.methodcall(uicontroller.tune_preview_printer._clickabcnote)}(evt, '#{id}')"}
Bernhard Weichel
@bwl21

I found out that if I use

Document.ready.then do |ready|
  @uicontroller = Controller.new
end

I can subsequently find my controller instance by

Opal.top.uicontroller

but it still depends on internal knowlege. ...

Elia Schito
@elia
@bwl21 have you tried attaching the event via DOM after the SVG has been attached to the document? I'm very familiar with events inside SVGs though, so I'm not really sure if it requires some special stuff.
Anyway I don't think you can avoid using globals easliy otherwise, Opal.top.… is still a global as you pointed out, so it would be any Opal class.
Bernhard Weichel
@bwl21
@elia attaching the events via DOM seems to be the common approach. So this is what I am currently doing. But I have several hundred events to attach. As it blocks the UI thread, it is a performance issue. Attaching all events takes about 300 msec. I also think that it creates lots of closures consuming memory. Performance is the main reason that I want to attach the events in the SVG string. So I created a constant for the string "Opal.top.uicontroller".
Bernhard Weichel
@bwl21
@elia you made me think twice ... I now attach the events via DOM again, but only the ones user moves the mouse on ( in a mouseover event). So I can reuse all of my code, SVG is smaller and performance is ok. I do not have to attach multiple events (mousdown, mouseup, mousemove) in the SVG string. Thanks. I was on the wrong way (like driving from Berlin to Brusses via New York :-) And I can still use the svg.draggable.js (https://github.com/wout/svg.draggable.js) library without inventing it new.
Elia Schito
@elia
@bwl21 great to hear that! πŸ‘πŸ‘πŸ‘
Elia Schito
@elia

@/all I'd like to thank @catmando for providing stickers for the codemotion conference that's being held in milan this week :tada: :tada: :tada: :tada: :tada: Thanks Mitch!!!

If you're participating to a conference and want some stickers to promote Opal ping me and we'll try to provide you some

IMG_7157.jpeg
Frederic ZINGG
@fzingg
:clap:
Jan Biedermann
@janbiedermann
:+1:
Guillaume Grossetie
@Mogztter
Sweat!
Tobias Sandelius
@sandelius
I've been programming in multiple languages for many, many, years and Ruby have always been my go to cause I really love both the syntax and community. I've looked at Opal from a distance for some time but recently gave it a try and I must say, GOOD JOB everyone involved!
Elia Schito
@elia
:heart:
Mitch VanDuyn
@catmando
@sandelius these guys are great. We have a large production app (www.catprint.com) that thanks to opal is 100% RUBY. The UI part is about 17K of opal code, using the hyperstack (www.hyperstack.org) framework.
In practice Opal == MRI Ruby, very reliable and solid.
Marko Kauzlaric
@MarkoKauzlaric
Good afternoon gents!
With do you think about Opal and building Client side with it? And what do you recommend.
likemike
@likemik60537659_twitter
I think Opal missed the momentum.
Mitch VanDuyn
@catmando
@MarkoKauzlaric as noted directly above its great. Rock solid, and increases developer productivity in several ways. 1) Ruby is simply easier to read, and more expressive. In general we find it take about 4 times as much JS code to achieve the same functionality. 2) If you are using Ruby server side, the not having to context switch saves more brain power than people think. 3) It allows my developers to think about the whole system (i.e. how does the whole function work from user experience, to server side issues) rather isolate programmers into backend and frontend.
Adrian Madrid
@aemadrid
@MarkoKauzlaric you should definitely check out https://hyperstack.org/
there are a lot of other opal frameworks out there but I don’t believe any is as actively developed as HS
matrixbot
@matrixbot
ryanprior I used Opal for a project where I already had a software library in Ruby, and wanted to create a web app to make it easier to consume directly. It would not have been a huge effort to reimplement the library in Javascript, or to put up a Ruby backend server and have the front-end written in Javascript to consume it, but completing the project with Opal and the Inesita framework only took a couple days, including learning time having never used either before (but lots of Ruby otherwise.) If I were in a similar situation again, I would not hesitate to give Inesita another crack.
ryanprior The completed web app in question is here: https://cyberark.github.io/conjur-policy-generator/
The source code for the web app is here: https://github.com/cyberark/conjur-policy-generator/blob/master/web
I chose Inesita in particular because it's lightweight, includes its own tools, doesn't assume you're using Rails, and has nice approachable documentation.
Forrest Chang
@fkchang
@MarkoKauzlaric the apps we have in production with opal use opal-jquery, and lissio - I've played around a lot with previous versions of hyperstack, just no production apps, so next big opal app I'll write I'll use that --- if not for the huge brain/code share behind react, I'd probably use @jgaskins 's clearwater
for similar reasons to @matrixbot in that it's lean and doesn't require rails and I respect @jgaskins tech approaches that project (and in general)
Mitch VanDuyn
@catmando
@fkchang - Can you help me with your rails comment? It is true that our top priority for hyperloop is to disengage from rails (which should not be a big issue) BUT that said, I am so curious. What is the big reason for not using rails?
Forrest Chang
@fkchang
@catmando don't get me wrong, I love rails and will use it for whenever it's appropriate, I was just saying that I not being bound to rails is a perk, react.rb was much more bound to rails than the current hyperstack. But that said, given all the mindshare behind React, it'd be silly to not use hyperstack, I don't want to have to write my own widgets as much as possible, which would be the big drawback of clearwater for me
Mitch VanDuyn
@catmando
@fkchang no but I am trying to understand the general use case where rails is perhaps NOT appropriate. Don't get me wrong intuitively we all agree decoupling from rails (i.e. just make it a rack middle ware) is the right approach if only from a maintenance perspective, but at the moment its "intuition" so that doesn't always lead to the best design choices.
so I am looking for the underlying reason somebody might want hyperstack but no rails...
well apart from the case that you have an existing API, and you are using hyperstack just on the client side. Kind of Hypstk
Forrest Chang
@fkchang
@catmando in general, if I'm mucking around I'll probably default to rails unless indicated elsewise, simply because whenever I've had, for example, a sinatra app that lasted any amount of time, I've ended up re implementing parts of rails - unless it's pure API. That said, there times where I want lighter, or faster or less bloated websocket support, I think in a number of cases I'd lean towards roda - though it's been a while and I probably forgot how to develop roda. And as always, I'd like consider a hyperstack/crystal app as appropriate for somethings (like speedy websocket support that doesn't require another process to push)
but otherwise, I've reimplemented too many parts of rails to not use rails unless indicated I shouldn't, in general
Mitch VanDuyn
@catmando
yes those are good points. In particular its motivation for getting hyperstack directly implemented on Rack so its as fast as possible. BTW what would u use for websocket support outside of rails? Currently Hyperstack support rails action-cable, pusher.com and simple polling. Is there some other standard packages we should think of having direct support for?
Forrest Chang
@fkchang
IIRC Roda supports websockets via Faye, i don't recall what additional requirements are needed except a suitable webserver - in my mind I envision something that has the same developer experience that kemal does w/websockets, i.e. you just setup a ws route and it works.
Jamie Gaskins
@jgaskins
Check out power_strip for WebSockets
@fkchang @catmando ^^
Mitch VanDuyn
@catmando
@jgaskins that looks great!
Forrest Chang
@fkchang
2jga
@jgaskins just stumbled on that the other day, btw, good job
Mitch VanDuyn
@catmando
.