These are chat archives for opal/opal

29th
Jan 2017
Bernhard Weichel
@bwl21
Jan 29 2017 15:45

@jgaskins Thanks for that hint. I copied the class to my application and tried thefollowing code

      def read_dir(dirname = "/")
        a = %x{#{@root}.filesListFolder({path: #{dirname}})}
        Bowser::ServiceWorker::Promise.from_native(a).then do |value|
          Bowser::ServiceWorker::Promise.new.tap do |promise|
            begin
              result = Native(value)[:entries].map { |i| i.name }
              promise.resolve(result)
            rescue Exception => error
              promise.reject(error.message)
            end
          end
        end
      end

It works in the good case but when I force an error such that the "inner" Promise is rejected, it does not go to the 'fail' path.

It does not got the fail path even if I make the "inner" promise always fail.
Jamie Gaskins
@jgaskins
Jan 29 2017 22:47
@bwl21 Good point. Returning promises has been difficult to make work for all cases. :-\