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");
6 dojo.declare("dojo.data.api.Notification", dojo.data.api.Read, {
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.
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).
25 // | function onSet(item, attribute, oldValue, newValue) {
26 // | //Do something with the information...
28 // | var store = new some.newStore();
29 // | dojo.connect(store, "onSet", onSet);
31 getFeatures: function(){
33 // See dojo.data.api.Read.getFeatures()
35 'dojo.data.api.Read': true,
36 'dojo.data.api.Notification': true
40 onSet: function(/* item */ item,
41 /* attribute-name-string */ attribute,
42 /* object | array */ oldValue,
43 /* object | array */ newValue){
45 // This function is called any time an item is modified via setValue, setValues, unsetAttribute, etc.
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.
53 // The item being modified.
55 // The attribute being changed represented as a string name.
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.
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'.
67 throw new Error('Unimplemented API: dojo.data.api.Notification.onSet');
70 onNew: function(/* item */ newItem, /*object?*/ parentInfo){
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.
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.
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:
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.
99 throw new Error('Unimplemented API: dojo.data.api.Notification.onNew');
102 onDelete: function(/* item */ deletedItem){
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.
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.
115 throw new Error('Unimplemented API: dojo.data.api.Notification.onDelete');