Sha256: 1e976b55c4839a12bf9dbb7f2067ee3ba687e392b9a07d1a8df773965f7113b8

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 KB

Contents

#= require joosy/core/joosy

#
# Comfortable and clever wrappers for timeouts management
#
# @mixin
#
Joosy.Modules.TimeManager =

  #
  # Registeres timeout for current object
  #
  # @param [Integer] timeout          Miliseconds to wait
  # @param [Function] action          Action to run on timeout
  #
  setTimeout: (timeout, action) ->
    @__timeouts ||= []

    timer = window.setTimeout (=> action()), timeout
    @__timeouts.push timer

    timer

  #
  # Registeres interval for current object
  #
  # @param [Integer] delay            Miliseconds between runs
  # @param [Function] action          Action to run
  #
  setInterval: (delay, action) ->
    @__intervals ||= []

    timer = window.setInterval (=> action()), delay
    @__intervals.push timer

    timer

  #
  # Drops all registered timeouts and intervals for this object
  #
  __clearTime: ->
    if @__intervals
      for entry in @__intervals
        window.clearInterval entry

    if @__timeouts
      for entry in @__timeouts
        window.clearTimeout entry

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
joosy-1.2.0.alpha.41 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.38 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.37 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.36 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.35 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.34 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.33 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.32 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.31 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.30 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.29 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.28 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.27 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.25 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.24 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.23 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.22 src/joosy/core/modules/time_manager.coffee
joosy-1.2.0.alpha.21 src/joosy/core/modules/time_manager.coffee