DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
      • types
        • ZoneSpec
        • makeZoneSpec
      • static
        • current
        • error
        • ignore
        • waitFor
      • prototype
        • addWait
        • data
        • removeWait
        • run
      • plugins
        • ./debug
        • ./timeout
      • modules
        • ./register
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-zone
  • /
  • ignore
  • / On this page
    • ignore

      function
      • source

      Zone.ignore(fn)

      Creates a function that, when called, will not track any calls. This might be needed if you are calling code that does unusual things, like using setTimeout recursively indefinitely.

      var Zone = require("can-zone");
      
      new Zone().run(function(){
          function recursive(){
              setTimeout(function(){
                  recursive();
              }, 20000);
          }
      
          var fn = Zone.ignore(recursive);
      
          // This call will not be waited on.
          fn();
      });
      

      Parameters

      1. fn {function}:

        A function that contains calls to asynchronous functions that are needing to be ignored.

      Returns

      {function}:

      A function in which calls to addWait and removeWait will be ignored, preventing the Zone's promise from remaining unresolved while asynchronous activity continues within.

      Use

      Zone.ignore is used to prevent a function from being waited on within a Zone. Normally a Zone's calls to functions like setTimeout and XMLHttpRequest are waited on before the run promise is resolved, but in some cases you might not want to wait on these calls; for example if there is a very long delay or a delay that will not result in rendering to take place.

      Provide Zone.ignore a function and it will return a function that can be called in it's place.

      var Zone = require("can-zone");
      
      var fn = Zone.ignore(function(){
          // do any asynchronous stuff here
      });
      
      fn(); // waits ignored
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.