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/
          • data interface
            • getListData
          • algebra
            • getDiff
            • getUnion
        • ./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
        • 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
  • /
  • ./cache-requests/
  • /
  • getDiff
  • / On this page
    • getDiff

      function

      Compares the available set data to the requested data and returns the data that should be loaded from the cache and the data loaded from the base connection.

      • source

      connection.getDiff( set, availableSets )

      This attempts to find the minimal amount of data to load by going through each availableSet and doing a subset test and a set difference with set.

      If set is a subset of an availableSet, {cached: set} will be returned.

      If there is a difference of set and an availableSet, the difference will be what's needed. The intersection of set and that availableSet will be what's cached. A count will be taken of what's needed resulting in an object like:

      {
        needed: {start: 50, end: 99},
        cached: {start: 0, end: 49},
        count: 49
      }
      

      Finally, getDiff will pick the diff objet with the lowest count. If there is no diff object, {needed: set} is returned.

      Parameters

      1. set {Set}:

        The set that is being loaded.

      2. availableSets {Array<Set>}:

        An array of available sets in the cacheConnection.

      Returns

      {Promise<Object>}:

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