-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1292b19
commit 07b779d
Showing
3 changed files
with
403 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/*can-super-model@1.1.1#can-super-model*/ | ||
define([ | ||
'require', | ||
'exports', | ||
'module', | ||
'can-connect', | ||
'can-connect/constructor', | ||
'can-connect/can/map', | ||
'can-connect/can/ref', | ||
'can-connect/constructor/store', | ||
'can-connect/data/callbacks', | ||
'can-connect/data/callbacks-cache', | ||
'can-connect/data/combine-requests', | ||
'can-connect/data/localstorage-cache', | ||
'can-connect/data/parse', | ||
'can-connect/data/url', | ||
'can-connect/fall-through-cache', | ||
'can-connect/real-time', | ||
'can-connect/constructor/callbacks-once', | ||
'can-define/list', | ||
'can-define/map', | ||
'can-namespace', | ||
'can-reflect', | ||
'can-query-logic' | ||
], function (require, exports, module) { | ||
var connect = require('can-connect'); | ||
var connectConstructor = require('can-connect/constructor'); | ||
var canMap = require('can-connect/can/map'); | ||
var canRef = require('can-connect/can/ref'); | ||
var constructorStore = require('can-connect/constructor/store'); | ||
var dataCallbacks = require('can-connect/data/callbacks'); | ||
var callbacksCache = require('can-connect/data/callbacks-cache'); | ||
var combineRequests = require('can-connect/data/combine-requests'); | ||
var localCache = require('can-connect/data/localstorage-cache'); | ||
var dataParse = require('can-connect/data/parse'); | ||
var dataUrl = require('can-connect/data/url'); | ||
var fallThroughCache = require('can-connect/fall-through-cache'); | ||
var realTime = require('can-connect/real-time'); | ||
var callbacksOnce = require('can-connect/constructor/callbacks-once'); | ||
var DefineList = require('can-define/list'); | ||
var DefineMap = require('can-define/map'); | ||
var namespace = require('can-namespace'); | ||
var canReflect = require('can-reflect'); | ||
var QueryLogic = require('can-query-logic'); | ||
function superModel(optionsOrUrl) { | ||
var options = typeof optionsOrUrl === 'string' ? { url: optionsOrUrl } : optionsOrUrl; | ||
if (typeof options.Map === 'undefined') { | ||
options.Map = DefineMap.extend({ seal: false }, {}); | ||
} | ||
if (typeof options.List === 'undefined') { | ||
options.List = options.Map.List || DefineList.extend({ '#': options.Map }); | ||
} | ||
options = canReflect.assignDeep({}, options); | ||
if (!options.name) { | ||
options.name = canReflect.getName(options.Map) + '.connection'; | ||
} | ||
if (!options.queryLogic) { | ||
options.queryLogic = new QueryLogic(options.Map); | ||
} | ||
var behaviors = [ | ||
connectConstructor, | ||
canMap, | ||
canRef, | ||
constructorStore, | ||
dataCallbacks, | ||
combineRequests, | ||
dataParse, | ||
dataUrl, | ||
realTime, | ||
callbacksOnce | ||
]; | ||
if (typeof localStorage !== 'undefined') { | ||
if (!options.cacheConnection) { | ||
options.cacheConnection = connect([localCache], { | ||
name: options.name + '.cacheConnection', | ||
idProp: options.idProp, | ||
queryLogic: options.queryLogic | ||
}); | ||
} | ||
behaviors.push(callbacksCache, fallThroughCache); | ||
} | ||
return connect(behaviors, options); | ||
} | ||
module.exports = namespace.superModel = superModel; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*can-super-model@1.1.1#can-super-model*/ | ||
var connect = require('can-connect'); | ||
var connectConstructor = require('can-connect/constructor/constructor'); | ||
var canMap = require('can-connect/can/map/map'); | ||
var canRef = require('can-connect/can/ref/ref'); | ||
var constructorStore = require('can-connect/constructor/store/store'); | ||
var dataCallbacks = require('can-connect/data/callbacks/callbacks'); | ||
var callbacksCache = require('can-connect/data/callbacks-cache/callbacks-cache'); | ||
var combineRequests = require('can-connect/data/combine-requests/combine-requests'); | ||
var localCache = require('can-connect/data/localstorage-cache/localstorage-cache'); | ||
var dataParse = require('can-connect/data/parse/parse'); | ||
var dataUrl = require('can-connect/data/url/url'); | ||
var fallThroughCache = require('can-connect/fall-through-cache/fall-through-cache'); | ||
var realTime = require('can-connect/real-time/real-time'); | ||
var callbacksOnce = require('can-connect/constructor/callbacks-once/callbacks-once'); | ||
var DefineList = require('can-define/list/list'); | ||
var DefineMap = require('can-define/map/map'); | ||
var namespace = require('can-namespace'); | ||
var canReflect = require('can-reflect'); | ||
var QueryLogic = require('can-query-logic'); | ||
function superModel(optionsOrUrl) { | ||
var options = typeof optionsOrUrl === 'string' ? { url: optionsOrUrl } : optionsOrUrl; | ||
if (typeof options.Map === 'undefined') { | ||
options.Map = DefineMap.extend({ seal: false }, {}); | ||
} | ||
if (typeof options.List === 'undefined') { | ||
options.List = options.Map.List || DefineList.extend({ '#': options.Map }); | ||
} | ||
options = canReflect.assignDeep({}, options); | ||
if (!options.name) { | ||
options.name = canReflect.getName(options.Map) + '.connection'; | ||
} | ||
if (!options.queryLogic) { | ||
options.queryLogic = new QueryLogic(options.Map); | ||
} | ||
var behaviors = [ | ||
connectConstructor, | ||
canMap, | ||
canRef, | ||
constructorStore, | ||
dataCallbacks, | ||
combineRequests, | ||
dataParse, | ||
dataUrl, | ||
realTime, | ||
callbacksOnce | ||
]; | ||
if (typeof localStorage !== 'undefined') { | ||
if (!options.cacheConnection) { | ||
options.cacheConnection = connect([localCache], { | ||
name: options.name + '.cacheConnection', | ||
idProp: options.idProp, | ||
queryLogic: options.queryLogic | ||
}); | ||
} | ||
behaviors.push(callbacksCache, fallThroughCache); | ||
} | ||
return connect(behaviors, options); | ||
} | ||
module.exports = namespace.superModel = superModel; |
Oops, something went wrong.