Class DataSource.Local
- extends Base
- Known Subclasses:
-
DataSource.Function
Pollable
DataSource.Get
DataSource.IO
Base class for the DataSource Utility.
Properties
Global transaction counter.
Default Value: 0
NAME
- static final String
Properties inherited from Base:
Methods
protected
void
_defDataFn
(
e
)
Normalizes raw data into a response that includes results and meta properties.
- Parameters:
-
e
<Event.Facade>
Event Facade with the following properties:
- tId (Number)
- Unique transaction ID.
- request (Object)
- The request.
- callback (Object)
- The callback object with the following properties:
- success (Function)
- Success handler.
- failure (Function)
- Failure handler.
- cfg (Object)
- Configuration object.
- data (Object)
- Raw data.
protected
void
_defRequestFn
(
e
)
Manages request/response transaction. Must fire response
event when response is received. This method should be implemented by
subclasses to achieve more complex behavior such as accessing remote data.
- Parameters:
-
e
<Event.Facade>
Event Facadewith the following properties:
- tId (Number)
- Unique transaction ID.
- request (Object)
- The request.
- callback (Object)
- The callback object with the following properties:
- success (Function)
- Success handler.
- failure (Function)
- Failure handler.
- cfg (Object)
- Configuration object.
protected
void
_defResponseFn
(
e
)
Sends data as a normalized response to callback.
- Parameters:
-
e
<Event.Facade>
Event Facade with the following properties:
- tId (Number)
- Unique transaction ID.
- request (Object)
- The request.
- callback (Object)
- The callback object with the following properties:
- success (Function)
- Success handler.
- failure (Function)
- Failure handler.
- cfg (Object)
- Configuration object.
- data (Object)
- Raw data.
- response (Object)
- Normalized response object with the following properties:
- results (Object)
- Parsed results.
- meta (Object)
- Parsed meta data.
- error (Boolean)
- Error flag.
private
void
_initEvents
(
)
This method creates all the events for this module.
static
void
DataSource.issueCallback
(
callback
,
params
,
error
)
Executes a given callback. The third param determines whether to execute
- Parameters:
-
callback
<Object>
The callback object.
-
params
<Array>
params to be passed to the callback method
-
error
<Boolean>
whether an error occurred
private
void
initializer
(
config
)
Internal init() handler.
- Parameters:
-
config
<Object>
Config object.
Number
sendRequest
(
request
,
callback
,
cfg
)
Generates a unique transaction ID and fires request
event.
- Parameters:
-
request
<Object>
Request.
-
callback
<Object>
An object literal with the following properties:
success
- The function to call when the data is ready.
failure
- The function to call upon a response failure condition.
argument
- Arbitrary data payload that will be passed back to the success and failure handlers.
-
cfg
<Object>
Configuration object
- Returns:
Number
- Transaction ID.
Methods inherited from EventTarget:
_getType,
_parseType,
addTarget,
after,
before,
bubble,
detach,
detachAll,
fire,
getEvent,
on,
publish,
removeTarget,
subscribe,
unsubscribe,
unsubscribeAll
Methods inherited from Attribute:
_addAttrs,
_addLazyAttr,
_defAttrChangeFn,
_fireAttrChange,
_getAttr,
_getAttrInitVal,
_getAttrs,
_getStateVal,
_isLazyAttr,
_normAttrVals,
_protectAttrs,
_set,
_setAttr,
_setAttrs,
_setAttrVal,
_setStateVal,
addAttr,
addAttrs,
attrAdded,
get,
getAttrs,
modifyAttr,
removeAttr,
reset,
set,
setAttrs
Methods inherited from Base:
_aggregateAttrs,
_defDestroyFn,
_defInitFn,
_destroyHierarchy,
_filterAttrCfs,
_getAttrCfgs,
_getClasses,
_initHierarchy,
_initHierarchyData,
destroy,
init,
toString
Events
data
(
e
)
Fired when raw data is received.
- Parameters:
-
e
<Event.Facade>
Event Facade with the following properties:
- tId (Number)
- Unique transaction ID.
- request (Object)
- The request.
- callback (Object)
- The callback object with the following properties:
- success (Function)
- Success handler.
- failure (Function)
- Failure handler.
- cfg (Object)
- Configuration object.
- data (Object)
- Raw data.
Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defDataFn.
error
(
e
)
Fired when an error is encountered.
- Parameters:
-
e
<Event.Facade>
Event Facade with the following properties:
- tId (Number)
- Unique transaction ID.
- request (Object)
- The request.
- callback (Object)
- The callback object with the following properties:
- success (Function)
- Success handler.
- failure (Function)
- Failure handler.
- cfg (Object)
- Configuration object.
- data (Object)
- Raw data.
- response (Object)
- Normalized response object with the following properties:
- results (Object)
- Parsed results.
- meta (Object)
- Parsed meta data.
- error (Object)
- Error object.
request
(
e
)
Fired when a data request is received.
- Parameters:
-
e
<Event.Facade>
Event Facade with the following properties:
- tId (Number)
- Unique transaction ID.
- request (Object)
- The request.
- callback (Object)
- The callback object.
- cfg (Object)
- Configuration object.
Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defRequestFn.
response
(
e
)
Fired when response is returned.
- Parameters:
-
e
<Event.Facade>
Event Facade with the following properties:
- tId (Number)
- Unique transaction ID.
- request (Object)
- The request.
- callback (Object)
- The callback object with the following properties:
- success (Function)
- Success handler.
- failure (Function)
- Failure handler.
- cfg (Object)
- Configuration object.
- data (Object)
- Raw data.
- response (Object)
- Normalized response object with the following properties:
- results (Object)
- Parsed results.
- meta (Object)
- Parsed meta data.
- error (Boolean)
- Error flag.
Preventable: This event is preventable by method e.preventDefault(). The default function executed by this event is _defResponseFn.
sourceChange
(
event
)
Fires when the value for the configuration attribute 'source' is changed. You can listen for the event using the
on method if you wish to be notified before the attribute's value has changed, or using the
after method if you wish to be notified after the attribute's value has changed.
- Parameters:
-
event
<Event.Facade>
An Event Facade object with the following attribute specific properties added: - prevVal
- The value of the attribute, prior to it being set
- newVal
- The value the attribute is to be set to
- attrName
- The name of the attribute being set
- subAttrName
- If setting a property within the attribute's value, the name of the sub-attribute property being set
Events inherited from Base:
Configuration attributes inherited from Base: