Sha256: ce61b3e16b848b516fba43c8f5373196a8c498a45d716d1fe240db15029f68ec

Contents?: true

Size: 788 Bytes

Versions: 82

Compression:

Stored size: 788 Bytes

Contents

require 'eventmachine'

module Ably::Modules
  # EventMachineHelpers module provides common private methods to classes simplifying interaction with EventMachine
  module EventMachineHelpers
    private

    # This method allows looped blocks to be run at the next EventMachine tick
    # @example
    #   x = 0
    #   less_than_3 = -> { x < 3 }
    #   non_blocking_loop_while(less_than_3) do
    #     x += 1
    #   end
    def non_blocking_loop_while(lambda_condition, &execution_block)
      if lambda_condition.call
        EventMachine.next_tick do
          if lambda_condition.call # ensure condition is still met following #next_tick
            yield
            non_blocking_loop_while(lambda_condition, &execution_block)
          end
        end
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 2 rubygems

Version Path
ably-rest-1.2.7 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.2.7 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.2.6 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.2.6 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.2.4 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.2.4 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.2.3 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.2.3 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.2.2 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.2.2 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.2.1 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.2.1 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.2.0 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.2.0 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.1.8 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.1.8 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.1.7 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.1.7 lib/ably/modules/event_machine_helpers.rb
ably-rest-1.1.6 lib/submodules/ably-ruby/lib/ably/modules/event_machine_helpers.rb
ably-1.1.6 lib/ably/modules/event_machine_helpers.rb