Sha256: 1ae4b86a56d76d51c0fa0acc5f2577d04ff1c381cc7a5334f8b58054bd486c6f

Contents?: true

Size: 446 Bytes

Versions: 3

Compression:

Stored size: 446 Bytes

Contents

module Hyperstack
  module AsyncSleep
    if RUBY_ENGINE == 'opal'
      def self.every(*args, &block)
        every(*args, &block)
      end

      def self.after(*args, &block)
        after(*args, &block)
      end
    else
      extend self

      def every(time, &block)
        Thread.new { loop { sleep time; block.call } }
      end

      def after(time, &block)
        Thread.new { sleep time; block.call }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hyper-operation-1.0.alpha1.8 lib/hyper-operation/async_sleep.rb
hyper-operation-1.0.alpha1.7 lib/hyper-operation/async_sleep.rb
hyper-operation-1.0.alpha1.6 lib/hyper-operation/async_sleep.rb