forked from fanruan/fineui
guy
7 years ago
9 changed files with 369 additions and 181 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,82 @@
|
||||
;(function () { |
||||
var constantInjection = {}; |
||||
BI.constant = function (xtype, cls) { |
||||
if (constantInjection[xtype] != null) { |
||||
throw ("constant:[" + xtype + "] has been registed"); |
||||
} |
||||
constantInjection[xtype] = cls; |
||||
}; |
||||
|
||||
var modelInjection = {}; |
||||
BI.model = function (xtype, cls) { |
||||
if (modelInjection[xtype] != null) { |
||||
throw ("model:[" + xtype + "] has been registed"); |
||||
} |
||||
modelInjection[xtype] = cls; |
||||
}; |
||||
|
||||
var storeInjection = {}; |
||||
BI.stores = function (xtype, cls) { |
||||
if (storeInjection[xtype] != null) { |
||||
throw ("store:[" + xtype + "] has been registed"); |
||||
} |
||||
storeInjection[xtype] = cls; |
||||
}; |
||||
|
||||
var providerInjection = {}; |
||||
BI.provider = function (xtype, cls) { |
||||
if (providerInjection[xtype] != null) { |
||||
throw ("provider:[" + xtype + "] has been registed"); |
||||
} |
||||
providerInjection[xtype] = cls; |
||||
}; |
||||
|
||||
BI.config = function (type, configFn) { |
||||
if (constantInjection[type]) { |
||||
return constantInjection[type] = configFn(constantInjection[type]); |
||||
} |
||||
if (providerInjection[type]) { |
||||
if (!providers[type]) { |
||||
providers[type] = new providerInjection[type](); |
||||
} |
||||
return configFn(providers[type]) |
||||
} |
||||
} |
||||
|
||||
BI.Constants = { |
||||
getConstant: function (type) { |
||||
return constantInjection[type]; |
||||
} |
||||
} |
||||
|
||||
BI.Models = { |
||||
getModel: function (type, config) { |
||||
return new modelInjection[type](config); |
||||
} |
||||
} |
||||
|
||||
var stores = {}; |
||||
|
||||
BI.Stores = { |
||||
getStore: function (type, config) { |
||||
if (stores[type]) { |
||||
return stores[type]; |
||||
} |
||||
return stores[type] = new storeInjection[type](config); |
||||
} |
||||
} |
||||
|
||||
var providers = {}, providerInstance = {} |
||||
|
||||
BI.Providers = { |
||||
getProvider: function (type, config) { |
||||
if (!providers[type]) { |
||||
providers[type] = new providerInjection[type](); |
||||
} |
||||
if (!providerInstance[type]) { |
||||
providerInstance[type] = new providers[type].$get()(config); |
||||
} |
||||
return providerInstance[type]; |
||||
} |
||||
} |
||||
})(); |
@ -1,15 +0,0 @@
|
||||
;(function () { |
||||
var models = {}; |
||||
BI.models = function (xtype, cls) { |
||||
if (models[xtype] != null) { |
||||
throw ("models:[" + xtype + "] has been registed"); |
||||
} |
||||
models[xtype] = cls; |
||||
}; |
||||
|
||||
BI.Models = { |
||||
getModel: function (type, config) { |
||||
return new models[type](config); |
||||
} |
||||
} |
||||
})(); |
@ -1,20 +0,0 @@
|
||||
;(function () { |
||||
var kv = {}; |
||||
BI.stores = function (xtype, cls) { |
||||
if (kv[xtype] != null) { |
||||
throw ("stores:[" + xtype + "] has been registed"); |
||||
} |
||||
kv[xtype] = cls; |
||||
}; |
||||
|
||||
var stores = {}; |
||||
|
||||
BI.Stores = { |
||||
getStore: function (type, config) { |
||||
if (stores[type]) { |
||||
return stores[type]; |
||||
} |
||||
return stores[type] = new kv[type](config); |
||||
} |
||||
} |
||||
})(); |
Loading…
Reference in new issue