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
  • /
  • waitFor
  • / On this page
    • waitFor

      function
      • source

      Zone.waitFor(fn)

      Zone.waitFor is a function that creates a callback that can be used with any async functionality. Calling Zone.waitFor registers a wait with the currently running request and returns a function that, when called, will decrement the wait count.

      This is useful if there is async functionality other than what we implement. You might be using a library that has C++ bindings and doesn't go through the normal JavaScript async APIs.

      var Zone = require("can-zone");
      var fs = require("fs");
      
      fs.readFile("data.json", "utf8", Zone.waitFor(function(){
          // We waited on this!
      }));
      

      Parameters

      1. fn {function}:

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