DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
      • behaviors
        • ./base/
        • ./cache-requests/
        • ./can/map/
        • ./can/ref/
        • ./constructor/callbacks-once/
        • ./constructor/
        • ./constructor/store/
        • ./data/callbacks/
        • ./data/callbacks-cache/
        • ./data/combine-requests/
        • ./data/localstorage-cache/
        • ./data/memory-cache/
        • ./data/parse/
        • ./data/url/
        • ./data/worker/
        • ./fall-through-cache/
        • ./real-time/
      • modules
        • ./can/base-map/
        • ./can/model/
        • ./can/super-map/
        • ./can/tag/
        • ./helpers/weak-reference-map
      • data types
        • DataInterface
          • clear
          • createData
          • destroyData
          • getData
          • getListData
          • getSets
          • updateData
          • updateListData
        • Instance
        • InstanceInterface
        • List
        • ListData
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-connect
  • /
  • DataInterface
  • /
  • getListData
  • / On this page
    • getListData

      typedef

      Retrieves list of records for the given set.

      • source

      function(set)

      Returns a promise that resolves to a ListData for a particular set.

      connection.getListData({complete: true}).then(function(listData){
          connection.hydrateList(listData);
      });
      

      Parameters

      1. set {Set}:

        A object that represents the set of data needed to be loaded. For example, {complete: true} might represent the set of all completed records.

      Returns

      {Promise<ListData>}:

      A promise that resolves to the ListData format like:

      {
        data: [
          {id: 1, name: "take out the trash"},
          {id: 1, name: "do the dishes"}
        ],
        count: 1000
      }
      

      Use

      Extensions like can-connect/data/url/url make it easy to implement getListData, but it can be as simple as:

      var connection = connect([],{
        getListData: function(set){
          return new Promise(function(resolve, reject){
              $.get("/api/todos",set).then(resolve, reject)
          });
        }
      })
      

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