These are chat archives for opal/opal

Jan 2017
Jamie Gaskins
Jan 30 2017 01:07
@bwl21 Bowser also has a branch with a pure-Ruby Promise implementation if that helps.
It also includes a from_native method.
Bernhard Weichel
Jan 30 2017 09:27

@jgaskins it seems that Bowser::ServiceWorker::Promise does not implement Promise.when as shown in

Composing Promises

Promise.when can be used to wait for more than 1 promise to resolve (or reject). Lets assume we wanted to get 2 different users:

first = get_json '/users/1.json'
second = get_json '/users/2.json'

Promise.when(first, second).then do |user1, user2|
  puts "got users: #{user1}, #{user2}" do
  alert "Something bad happened"

opened an issue on github

Bernhard Weichel
Jan 30 2017 16:28
@jgaskins I returned to Opal's promise in my project. I had to build an adapter to the new Dropbox-API anyhow. But it might be of interest, that I had replaced Promise by Bowser::ServiceWorker::Promise and it mainly worked (except "when"). I did not want to change too many parts at the same time, therefore, I returned.