Notes/summary from weekend discussion (Jan, 31).
nil == null == undefined
nil # => null
true # => true
false # => false| Promise.new do |promise| | |
| HTTP.get(url, :GET, opts) do |response| | |
| if response.ok? | |
| promise.resolve response | |
| else | |
| promise.reject response | |
| end | |
| end | |
| end |
| $window.setTimeout -> do | |
| a = $document.createElement 'div' | |
| a.innerHTML = "hi there" | |
| $document.body.appendChild a | |
| puts a.innerHTML | |
| end, 0 |
| require 'opal' | |
| require 'sinatra' | |
| get '/' do | |
| <<-EOS | |
| <!doctype html> | |
| <html> | |
| <head> | |
| <script src="/assets/application.js"></script> | |
| </head> |
| .row | |
| .col-md-8 | |
| %h2 Items | |
| .col-md-3 | |
| %h2 Shopping List | |
| = bind_unless cart_empty? do | |
| %a.btn.btn-default#clear-cart(style="width: 50%") | |
| = bind clear_title |
| module LocalStorage | |
| def self.[](name) | |
| `localStorage.getItem(name)` | |
| end | |
| def self.[]=(name, value) | |
| `localStorage.setItem(name, value)` | |
| end | |
| def self.key?(name) |
| // runtime | |
| Opal.modules = {}; | |
| Opal.register = function(name, body) { | |
| Opal.modules[name] = body; | |
| }; | |
| Opal.require = function(name) { | |
| var module = Opal.modules[name]; | |
| class Bar < Foo | |
| end |
| require 'opal' | |
| require 'rails_templates' | |
| p Template.paths | |
| # => ['login', 'logout', 'user', 'user/new'] |
| describe NewProductView do | |
| # do we have to repeat this? | |
| view NewProductView | |
| it "tries to add product on click submit" do | |
| expect(view).to receive(:add_product).once | |
| find('#submit').click | |
| end | |
| end |