2150 |
mathias |
1 |
if(!dojo._hasResource["dojo.data.api.Notification"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojo.data.api.Notification"] = true;
|
|
|
3 |
dojo.provide("dojo.data.api.Notification");
|
|
|
4 |
dojo.require("dojo.data.api.Read");
|
|
|
5 |
|
|
|
6 |
dojo.declare("dojo.data.api.Notification", dojo.data.api.Read, {
|
|
|
7 |
// summary:
|
|
|
8 |
// This is an abstract API that data provider implementations conform to.
|
|
|
9 |
// This file defines functions signatures and intentionally leaves all the
|
|
|
10 |
// functions unimplemented.
|
|
|
11 |
//
|
|
|
12 |
// description:
|
|
|
13 |
// This API defines a set of APIs that all datastores that conform to the
|
|
|
14 |
// Notifications API must implement. In general, most stores will implement
|
|
|
15 |
// these APIs as no-op functions for users who wish to monitor them to be able
|
|
|
16 |
// to connect to then via dojo.connect(). For non-users of dojo.connect,
|
|
|
17 |
// they should be able to just replace the function on the store to obtain
|
|
|
18 |
// notifications. Both read-only and read-write stores may implement
|
|
|
19 |
// this feature. In the case of a read-only store, this feature makes sense if
|
|
|
20 |
// the store itself does internal polling to a back-end server and periodically updates
|
|
|
21 |
// its cache of items (deletes, adds, and updates).
|
|
|
22 |
//
|
|
|
23 |
// example:
|
|
|
24 |
//
|
|
|
25 |
// | function onSet(item, attribute, oldValue, newValue) {
|
|
|
26 |
// | //Do something with the information...
|
|
|
27 |
// | };
|
|
|
28 |
// | var store = new some.newStore();
|
|
|
29 |
// | dojo.connect(store, "onSet", onSet);
|
|
|
30 |
|
|
|
31 |
getFeatures: function(){
|
|
|
32 |
// summary:
|
|
|
33 |
// See dojo.data.api.Read.getFeatures()
|
|
|
34 |
return {
|
|
|
35 |
'dojo.data.api.Read': true,
|
|
|
36 |
'dojo.data.api.Notification': true
|
|
|
37 |
};
|
|
|
38 |
},
|
|
|
39 |
|
|
|
40 |
onSet: function(/* item */ item,
|
|
|
41 |
/* attribute-name-string */ attribute,
|
|
|
42 |
/* object | array */ oldValue,
|
|
|
43 |
/* object | array */ newValue){
|
|
|
44 |
// summary:
|
|
|
45 |
// This function is called any time an item is modified via setValue, setValues, unsetAttribute, etc.
|
|
|
46 |
// description:
|
|
|
47 |
// This function is called any time an item is modified via setValue, setValues, unsetAttribute, etc.
|
|
|
48 |
// Its purpose is to provide a hook point for those who wish to monitor actions on items in the store
|
|
|
49 |
// in a simple manner. The general expected usage is to dojo.connect() to the store's
|
|
|
50 |
// implementation and be called after the store function is called.
|
|
|
51 |
//
|
|
|
52 |
// item:
|
|
|
53 |
// The item being modified.
|
|
|
54 |
// attribute:
|
|
|
55 |
// The attribute being changed represented as a string name.
|
|
|
56 |
// oldValue:
|
|
|
57 |
// The old value of the attribute. In the case of single value calls, such as setValue, unsetAttribute, etc,
|
|
|
58 |
// this value will be generally be an atomic value of some sort (string, int, etc, object). In the case of
|
|
|
59 |
// multi-valued attributes, it will be an array.
|
|
|
60 |
// newValue:
|
|
|
61 |
// The new value of the attribute. In the case of single value calls, such as setValue, this value will be
|
|
|
62 |
// generally be an atomic value of some sort (string, int, etc, object). In the case of multi-valued attributes,
|
|
|
63 |
// it will be an array. In the case of unsetAttribute, the new value will be 'undefined'.
|
|
|
64 |
//
|
|
|
65 |
// returns:
|
|
|
66 |
// Nothing.
|
|
|
67 |
throw new Error('Unimplemented API: dojo.data.api.Notification.onSet');
|
|
|
68 |
},
|
|
|
69 |
|
|
|
70 |
onNew: function(/* item */ newItem, /*object?*/ parentInfo){
|
|
|
71 |
// summary:
|
|
|
72 |
// This function is called any time a new item is created in the store.
|
|
|
73 |
// It is called immediately after the store newItem processing has completed.
|
|
|
74 |
// description:
|
|
|
75 |
// This function is called any time a new item is created in the store.
|
|
|
76 |
// It is called immediately after the store newItem processing has completed.
|
|
|
77 |
//
|
|
|
78 |
// newItem:
|
|
|
79 |
// The item created.
|
|
|
80 |
// parentInfo:
|
|
|
81 |
// An optional javascript object that is passed when the item created was placed in the store
|
|
|
82 |
// hierarchy as a value f another item's attribute, instead of a root level item. Note that if this
|
|
|
83 |
// function is invoked with a value for parentInfo, then onSet is not invoked stating the attribute of
|
|
|
84 |
// the parent item was modified. This is to avoid getting two notification events occurring when a new item
|
|
|
85 |
// with a parent is created. The structure passed in is as follows:
|
|
|
86 |
// {
|
|
|
87 |
// item: someItem, //The parent item
|
|
|
88 |
// attribute: "attribute-name-string", //The attribute the new item was assigned to.
|
|
|
89 |
// oldValue: something //Whatever was the previous value for the attribute.
|
|
|
90 |
// //If it is a single-value attribute only, then this value will be a single value.
|
|
|
91 |
// //If it was a multi-valued attribute, then this will be an array of all the values minues the new one.
|
|
|
92 |
// newValue: something //The new value of the attribute. In the case of single value calls, such as setValue, this value will be
|
|
|
93 |
// //generally be an atomic value of some sort (string, int, etc, object). In the case of multi-valued attributes,
|
|
|
94 |
// //it will be an array.
|
|
|
95 |
// }
|
|
|
96 |
//
|
|
|
97 |
// returns:
|
|
|
98 |
// Nothing.
|
|
|
99 |
throw new Error('Unimplemented API: dojo.data.api.Notification.onNew');
|
|
|
100 |
},
|
|
|
101 |
|
|
|
102 |
onDelete: function(/* item */ deletedItem){
|
|
|
103 |
// summary:
|
|
|
104 |
// This function is called any time an item is deleted from the store.
|
|
|
105 |
// It is called immediately after the store deleteItem processing has completed.
|
|
|
106 |
// description:
|
|
|
107 |
// This function is called any time an item is deleted from the store.
|
|
|
108 |
// It is called immediately after the store deleteItem processing has completed.
|
|
|
109 |
//
|
|
|
110 |
// deletedItem:
|
|
|
111 |
// The item deleted.
|
|
|
112 |
//
|
|
|
113 |
// returns:
|
|
|
114 |
// Nothing.
|
|
|
115 |
throw new Error('Unimplemented API: dojo.data.api.Notification.onDelete');
|
|
|
116 |
}
|
|
|
117 |
});
|
|
|
118 |
|
|
|
119 |
}
|