Git Product home page Git Product logo

Comments (4)

zverok avatar zverok commented on August 24, 2024

Hi (I'm Victor Shepelev from ruby-talk, we chatted about your awesome library there).
Have your considered usage of Launchy gem? It seems like exactly suiting the task "just launch default browser".

BTW, when I've thought about similar library, I thought there's no need in complications like WebSockets. In any case, both "main" code (irb, for ex.) and "webserver" are in the same process, so they could exchange information through just variables or something. This approach eliminates need for EventMachine, something simple could work:

require 'sinatra/base'

$bad_global = 1

class TestMe < Sinatra::Base
  get '/' do
    $bad_global += 1 
    'it works!'
  end
end

Thread.new{
  TestMe.set :server, :webrick
  TestMe.run!(port: 1234)
}

trap('INT'){
  exit
}

loop do
  p "tick! global: #{$bad_global}"
  sleep(1)
end

OK, globals are bad, but something not-that-bad can be used.

from flammarion.

zach-capalbo avatar zach-capalbo commented on August 24, 2024

Hi Victor,

I hadn't heard of Launchy. Thanks for pointing it out!

The main reason I initially tied Flammarion to Chrome and then started adding the option of Electron is they have command line options for launching without any browser-like trappings, which gives flammarion windows a more native application-like feeling, rather than a webpage feeling. Launchy will definitely be a nice fallback mechanism, though.

I agree that the dependency on EventMachine is annoying; however, websockets work perfectly for this approach. There needs to be constant two-way communication between from ruby process (for when commands like puts or button get called) to the javascript interpreter (i.e., the browser), and from the javascript interpreter back to the ruby process (for when the user clicks a button, or types in some input). Sending JSON messages over WebSockets handles this really well. Maybe I'll just write a pure ruby websockets server eventually.

I initially started out writing little interfaces with Sinatra, like you suggest. The issues I mostly ran into were things like how to push changes to the page from the ruby process (you could use AJAX and polling, but that's kind of annoying). And creating new routes all the time to display different kinds of information got tedious. It's totally doable, but I abandoned the approach when it got annoying. (Not to dissuade you from trying out your approach, of course; that's just what I encountered.)

Thanks for the feedback! I really appreciate the interest in this project!

from flammarion.

zverok avatar zverok commented on August 24, 2024

I agree that the dependency on EventMachine is annoying; however, websockets work perfectly for this approach.

Ah, ok, I see now. Quick googling showed up all Ruby WebSocket implementations are EventMachine-dependent :( Maybe some "naive" implementation can work in this case ... Will think about it.

from flammarion.

zach-capalbo avatar zach-capalbo commented on August 24, 2024

Hmm.. There is https://github.com/imanel/websocket-ruby and https://github.com/saward/Rubame seems like it should be fairly easy to remove event machine. Adding it to the todo list (#19)

Update: It was actually really easy: 144a40f

from flammarion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.