|
31 | 31 | })(function($, CustomStore, dataUtils) { |
32 | 32 | "use strict"; |
33 | 33 |
|
34 | | - function createStore(options) { |
35 | | - var store = new CustomStore(createStoreConfig(options)); |
36 | | - store._useDefaultSearch = true; |
37 | | - return store; |
38 | | - } |
| 34 | + var CUSTOM_STORE_OPTIONS = [ |
| 35 | + "onLoading", "onLoaded", |
| 36 | + "onInserting", "onInserted", |
| 37 | + "onUpdating", "onUpdated", |
| 38 | + "onRemoving", "onRemoved", |
| 39 | + "onModifying", "onModified", |
| 40 | + "onPush", |
| 41 | + "loadMode", "cacheRawData", |
| 42 | + "errorHandler" |
| 43 | + ]; |
39 | 44 |
|
40 | 45 | function createStoreConfig(options) { |
41 | 46 | var keyExpr = options.key, |
|
156 | 161 | d.resolve(isJSON ? JSON.parse(res) : res); |
157 | 162 | } |
158 | 163 |
|
159 | | - return { |
| 164 | + var result = { |
160 | 165 | key: keyExpr, |
161 | | - errorHandler: options.errorHandler, |
162 | | - loadMode: options.loadMode, |
| 166 | + useDefaultSearch: true, |
163 | 167 |
|
164 | 168 | load: function(loadOptions) { |
165 | 169 | return send( |
|
250 | 254 | } |
251 | 255 |
|
252 | 256 | }; |
| 257 | + |
| 258 | + CUSTOM_STORE_OPTIONS.forEach(function(name) { |
| 259 | + var value = options[name]; |
| 260 | + if(value !== undefined) |
| 261 | + result[name] = value; |
| 262 | + }); |
| 263 | + |
| 264 | + return result; |
253 | 265 | } |
254 | 266 |
|
255 | 267 | function processLoadResponse(d, res, getResolveArgs) { |
|
367 | 379 | } |
368 | 380 |
|
369 | 381 | return { |
370 | | - createStore: createStore |
| 382 | + createStore: function(options) { |
| 383 | + return new CustomStore(createStoreConfig(options)); |
| 384 | + } |
371 | 385 | }; |
372 | 386 | }); |
0 commit comments