2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('datasource-function', function (Y, NAME) {
11 * Provides a DataSource implementation which can be used to retrieve data from
15 * @submodule datasource-function
19 * Function subclass for the DataSource Utility.
20 * @class DataSource.Function
21 * @extends DataSource.Local
27 DSFn.superclass.constructor.apply(this, arguments);
31 /////////////////////////////////////////////////////////////////////////////
33 // DataSource.Function static properties
35 /////////////////////////////////////////////////////////////////////////////
44 * @value "dataSourceFunction"
46 NAME: "dataSourceFunction",
49 /////////////////////////////////////////////////////////////////////////////
51 // DataSource.Function Attributes
53 /////////////////////////////////////////////////////////////////////////////
57 * Stores the function that will serve the response data.
64 validator: LANG.isFunction
69 Y.extend(DSFn, Y.DataSource.Local, {
71 * Passes query data to the source function. Fires <code>response</code>
72 * event with the function results (synchronously).
74 * @method _defRequestFn
75 * @param e {Event.Facade} Event Facade with the following properties:
77 * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
78 * <dt>request (Object)</dt> <dd>The request.</dd>
79 * <dt>callback (Object)</dt> <dd>The callback object with the following
82 * <dt>success (Function)</dt> <dd>Success handler.</dd>
83 * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
86 * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
90 _defRequestFn: function(e) {
91 var fn = this.get("source"),
92 payload = e.details[0];
96 payload.data = fn(e.request, this, e);
101 payload.error = new Error("Function data failure");
104 this.fire("data", payload);
110 Y.DataSource.Function = DSFn;
113 }, '3.13.0', {"requires": ["datasource-local"]});