3
Copyright 2011 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
YUI.add('datasource-function', function(Y) {
10
* Provides a DataSource implementation which can be used to retrieve data from a custom function.
13
* @submodule datasource-function
17
* Function subclass for the DataSource Utility.
18
* @class DataSource.Function
19
* @extends DataSource.Local
25
DSFn.superclass.constructor.apply(this, arguments);
29
/////////////////////////////////////////////////////////////////////////////
31
// DataSource.Function static properties
33
/////////////////////////////////////////////////////////////////////////////
42
* @value "dataSourceFunction"
44
NAME: "dataSourceFunction",
47
/////////////////////////////////////////////////////////////////////////////
49
// DataSource.Function Attributes
51
/////////////////////////////////////////////////////////////////////////////
56
* @description Pointer to live data.
61
validator: LANG.isFunction
66
Y.extend(DSFn, Y.DataSource.Local, {
68
* Passes query string to IO. Fires <code>response</code> event when
69
* response is received asynchronously.
71
* @method _defRequestFn
72
* @param e {Event.Facade} Event Facade with the following properties:
74
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
75
* <dt>request (Object)</dt> <dd>The request.</dd>
76
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
78
* <dt>success (Function)</dt> <dd>Success handler.</dd>
79
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
82
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
86
_defRequestFn: function(e) {
87
var fn = this.get("source"),
88
payload = e.details[0];
92
payload.data = fn(e.request, this, e);
97
payload.error = new Error("Function data failure");
100
this.fire("data", payload);
106
Y.DataSource.Function = DSFn;
109
}, '3.4.1' ,{requires:['datasource-local']});