Comments (4)
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.
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.
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.
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)
- Cygwin process won't exit after wait until closed
- Enable spell checker for electron
- Integrate Plotly
- f.map("Boston, MA") shows nothing on Windows HOT 7
- Subpane margin
- Does flammarion run on a MAC? HOT 6
- Save plot to svg HOT 1
- Flammarion::Plot.new shortcut
- phantomjs backend
- Semantic Versioning
- Remove redcarpet
- Callback errors
- Flammarion opens regular Chrome browser HOT 1
- Use better webview HOT 2
- Use onInput rather than onChange for Input / TextArea
- Plot outside pane HOT 2
- Crash when creating Engraving HOT 1
- [Documentation] How does it work? HOT 1
- Selecting another browser via flammarion directly
- Generating .jpg .pdf files and so forth
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flammarion.