Class: Dry::Effects::Providers::Async

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/effects/providers/async.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stackObject (readonly)

Returns the value of attribute stack.



11
12
13
# File 'lib/dry/effects/providers/async.rb', line 11

def stack
  @stack
end

Instance Method Details

#async(block) ⇒ Object



13
14
15
# File 'lib/dry/effects/providers/async.rb', line 13

def async(block)
  @tasks[block] = block
end

#await(task) ⇒ Object



17
18
19
# File 'lib/dry/effects/providers/async.rb', line 17

def await(task)
  Frame.spawn_fiber(stack, &@tasks.delete(task))
end

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yield the block with the handler installed



24
25
26
27
28
# File 'lib/dry/effects/providers/async.rb', line 24

def call
  @stack = Frame.stack
  super
  nil
end