Notes/summary from weekend discussion (Jan, 31).
nil == null == undefined
nil # => null
true # => true
false # => false
.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 |
require 'opal' | |
require 'sinatra' | |
get '/' do | |
<<-EOS | |
<!doctype html> | |
<html> | |
<head> | |
<script src="/assets/application.js"></script> | |
</head> |
$window.setTimeout -> do | |
a = $document.createElement 'div' | |
a.innerHTML = "hi there" | |
$document.body.appendChild a | |
puts a.innerHTML | |
end, 0 |
Promise.new do |promise| | |
HTTP.get(url, :GET, opts) do |response| | |
if response.ok? | |
promise.resolve response | |
else | |
promise.reject response | |
end | |
end | |
end |
The idea is that we are binding an attribute cart_empty
on the current
object to get updated when some remote attribute on some other object
changes. This results in a method call current_obj.cart_empty = new_value
.
bind(:cart_empty).to observe(@cart, :empty?)
bind(:cart_empty).to @cart.observe(:empty?)
bind :cart_empty, @cart.observe(:empty?)
RACSignal *nameSignal = [RACObserve(self, someManagedObject.name) distinctUntilChanged];
RAC(self, someTextField.text) = [nameSignal deliverOn:[RACScheduler mainThreadScheduler]];
signal = observe(self, "some_managed_object.name")
signal.on_value { |val| self.some_text_field.text = val }
require 'opal-jquery/version' | |
if RUBY_ENGINE == "opal" | |
require 'opal-jquery/window' | |
require 'opal-jquery/document' | |
require 'opal-jquery/element' | |
require 'opal-jquery/event' | |
require 'opal-jquery/http' | |
require 'opal-jquery/kernel' | |
end |
module Vienna | |
class BaseBinding | |
def initialize(view, context, node, attr) | |
@view = view | |
@context = context | |
@node = node | |
@attr = attr | |
setup_binding | |
end |