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
      • types
        • Store
          • prototype
            • createData
            • destroyData
            • get
            • getData
            • getList
            • getListData
            • reset
            • updateData
        • ajaxSettings
        • request
        • requestHandler
        • response
      • properties
        • delay
        • on
        • rand
        • store
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-fixture
  • /
  • Store
  • /
  • reset
  • / On this page
    • reset

      function
      • source

      Store.prototype.reset([baseItems])

      Sets the items in the store to their original state or to baseItems if it's passed as an argument.

      // Creates a store with one item.
      var todoStore = fixture.store(
          [{id: 1, name: "dishes"}],
          new set.Algebra());
      fixture("/todos/{id}", todoStore)
      todoStore.getList({}).length //-> 1
      
      // delete that item
      $.ajax({url: "todos/1", method: "delete"}).then(function(){
          return todoStore.getList({}).length //-> 0
      }).then(function(){
          // calling reset adds it back
          todoStore.reset();
          todoStore.getList({}).length //-> 1
      });
      

      Parameters

      1. baseItems {Array}:

        If provided, adds these items to the store.
        This can be useful for setting up particular testing scenarios.

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