Module: BubbleWrap::Reactor::Future

Defined in:
motion/reactor/future.rb

Instance Method Summary collapse

Instance Method Details

#future(arg, cb = nil, eb = nil, &blk) ⇒ Object

A future is a sugaring of a typical deferrable usage.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'motion/reactor/future.rb', line 6

def future arg, cb=nil, eb=nil, &blk
  arg = arg.call if arg.respond_to?(:call)

  if arg.respond_to?(:set_deferred_status)
    if cb || eb
      arg.callback(&cb) if cb
      arg.errback(&eb) if eb
    else
      arg.callback(&blk) if blk
    end
  end

  arg
end