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

      function
      • source

      zone.run(fn)

      Runs a function within a Zone. Calling run will set the Zone's internal Promise which will only resolve once all asynchronous calls within fn are complete.

      Parameters

      1. fn {function}:

        Any function which needs to run within the Zone. The function will be executed immediately.

      Returns

      {Promise<data>}:

      Returns a promise that will resolve with the Zone's data object.

      var zone = new Zone();
      
      zone.run(function(){
      
          setTimeout(function(){
              zone.data.foo = "bar";
          });
      
      }).then(function(data){
          data.foo // -> "bar"
      });
      

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