DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
    • can-control
    • can-event
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
      • types
        • getTrapped
        • Observed
      • static
        • add
        • addAll
        • ignore
        • isRecording
        • trap
      • prototype
        • start
        • stop
    • can-simple-map
    • can-util
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-observation
  • /
  • trap
  • / On this page
    • trap

      function
      • source

      Observation.trap()

      Trap all observations until the untrap function is called. The state of traps prior to Observation.trap() will be restored when untrap() is called.

      var untrap = Observation.trap();
      
      Observation.add(obj, "prop1");
      
      var traps = untrap();
      console.log(traps[0].obj === obj); // -> true
      

      Returns

      {getTrapped()}:

      A function to get the trapped observations.

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