-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObservable.js
29 lines (27 loc) · 948 Bytes
/
Observable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*global define: true */
define([
"dojo/store/Observable"
], function (
Observable
) {
"use strict";
return function (s) {
var store = Observable(s), oldQuery = store.query;
store.query = function (query, options) {
var result = oldQuery(query, options), oldObserve = result.observe;
result.observe = function (listener, includeObjectUpdates) {
var l = function (item, removedIndex, insertedIndex) {
var model = item;
if (!(typeof item.deserialize === 'function')) {
model = store.getModelInstance();
model.deserialize(item);
}
return listener(model, removedIndex, insertedIndex);
};
return oldObserve(l, includeObjectUpdates);
};
return result;
};
return store;
};
});