]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/data/api/Notification.js.uncompressed.js
1 define("dojo/data/api/Notification", ["../../_base/declare", "./Read"], function(declare
, Read
){
4 // dojo/data/api/Notification
6 return declare("dojo.data.api.Notification", 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.
12 // This API defines a set of APIs that all datastores that conform to the
13 // Notifications API must implement. In general, most stores will implement
14 // these APIs as no-op functions for users who wish to monitor them to be able
15 // to connect to then via dojo.connect(). For non-users of dojo.connect,
16 // they should be able to just replace the function on the store to obtain
17 // notifications. Both read-only and read-write stores may implement
18 // this feature. In the case of a read-only store, this feature makes sense if
19 // the store itself does internal polling to a back-end server and periodically updates
20 // its cache of items (deletes, adds, and updates).
22 // | function onSet(item, attribute, oldValue, newValue){
23 // | //Do something with the information...
25 // | var store = new some.newStore();
26 // | dojo.connect(store, "onSet", onSet);
28 getFeatures: function(){
30 // See dojo/data/api/Read.getFeatures()
32 'dojo.data.api.Read': true,
33 'dojo.data.api.Notification': true
37 onSet: function(/* dojo/data/api/Item */ item,
38 /* attribute-name-string */ attribute
,
39 /* object|array */ oldValue
,
40 /* object|array */ newValue
){
42 // This function is called any time an item is modified via setValue, setValues, unsetAttribute, etc.
44 // This function is called any time an item is modified via setValue, setValues, unsetAttribute, etc.
45 // Its purpose is to provide a hook point for those who wish to monitor actions on items in the store
46 // in a simple manner. The general expected usage is to dojo.connect() to the store's
47 // implementation and be called after the store function is called.
49 // The item being modified.
51 // The attribute being changed represented as a string name.
53 // The old value of the attribute. In the case of single value calls, such as setValue, unsetAttribute, etc,
54 // this value will be generally be an atomic value of some sort (string, int, etc, object). In the case of
55 // multi-valued attributes, it will be an array.
57 // The new value of the attribute. In the case of single value calls, such as setValue, this value will be
58 // generally be an atomic value of some sort (string, int, etc, object). In the case of multi-valued attributes,
59 // it will be an array. In the case of unsetAttribute, the new value will be 'undefined'.
62 throw new Error('Unimplemented API: dojo.data.api.Notification.onSet');
65 onNew: function(/* dojo/data/api/Item */ newItem, /*object?*/ parentInfo
){
67 // This function is called any time a new item is created in the store.
68 // It is called immediately after the store newItem processing has completed.
70 // This function is called any time a new item is created in the store.
71 // It is called immediately after the store newItem processing has completed.
75 // An optional javascript object that is passed when the item created was placed in the store
76 // hierarchy as a value f another item's attribute, instead of a root level item. Note that if this
77 // function is invoked with a value for parentInfo, then onSet is not invoked stating the attribute of
78 // the parent item was modified. This is to avoid getting two notification events occurring when a new item
79 // with a parent is created. The structure passed in is as follows:
81 // | item: someItem, //The parent item
82 // | attribute: "attribute-name-string", //The attribute the new item was assigned to.
83 // | oldValue: something //Whatever was the previous value for the attribute.
84 // | //If it is a single-value attribute only, then this value will be a single value.
85 // | //If it was a multi-valued attribute, then this will be an array of all the values minus the new one.
86 // | newValue: something //The new value of the attribute. In the case of single value calls, such as setValue, this value will be
87 // | //generally be an atomic value of some sort (string, int, etc, object). In the case of multi-valued attributes,
88 // | //it will be an array.
92 throw new Error('Unimplemented API: dojo.data.api.Notification.onNew');
95 onDelete: function(/* dojo/data/api/Item */ deletedItem){
97 // This function is called any time an item is deleted from the store.
98 // It is called immediately after the store deleteItem processing has completed.
100 // This function is called any time an item is deleted from the store.
101 // It is called immediately after the store deleteItem processing has completed.
106 throw new Error('Unimplemented API: dojo.data.api.Notification.onDelete');