Sha256: d7f198f55a60215ed88be708595cef1cc88b0fb2024df6b2871966a2964a604e

Contents?: true

Size: 1.49 KB

Versions: 39

Compression:

Stored size: 1.49 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            Portions ©2008-2011 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

SC.mixin(Function.prototype, /** @scope Function.prototype */ {

  /**
    Creates a timer that will execute the function after a specified 
    period of time.
    
    If you pass an optional set of arguments, the arguments will be passed
    to the function as well.  Otherwise the function should have the 
    signature:
    
        function functionName(timer)

    @param target {Object} optional target object to use as this
    @param interval {Number} the time to wait, in msec
    @returns {SC.Timer} scheduled timer
  */
  invokeLater: function(target, interval) {
    if (interval === undefined) interval = 1 ;
    var f = this;
    if (arguments.length > 2) {
      var args = SC.$A(arguments).slice(2,arguments.length);
      args.unshift(target);
      // f = f.bind.apply(f, args) ;
      var func = f ;
      // Use "this" in inner func because it get its scope by 
      // outer func f (=target). Could replace "this" with target for clarity.
      f = function() { return func.apply(this, args.slice(1)); } ;
    }
    return SC.Timer.schedule({ target: target, action: f, interval: interval });
  }

});

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
sproutcore-1.11.0 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.11.0.rc3 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.11.0.rc2 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.11.0.rc1 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.10.3.1 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.10.2 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.10.1 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.10.0 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.10.0.rc.3 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.10.0.rc.2 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.10.0.rc.1 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.9.2 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.9.1 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.9.0 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/core_foundation/ext/function.js