Module: Puppeteer::ConcurrentRubyUtils::ConcurrentPromisesFutureExtension

Defined in:
lib/puppeteer/concurrent_ruby_utils.rb

Instance Method Summary collapse

Instance Method Details

#with_waiting_for_complete(&block) ⇒ Object

Extension for describing 2 concurrent tasks smartly.

page.async_wait_for_navigation.with_waiting_for_complete do

page.click('#submit')

end



9
10
11
12
13
14
15
16
17
18
# File 'lib/puppeteer/concurrent_ruby_utils.rb', line 9

def with_waiting_for_complete(&block)
  async_block_call = Concurrent::Promises.delay do
    block.call
  rescue => err
    Logger.new($stderr).warn(err)
    raise err
  end

  Concurrent::Promises.zip(self, async_block_call).value!.first
end