Grape.Resource Class
An abstract class to represent a resource. A resource can load itself, and can tell the estimated time to load it (default:1).
Methods
emit
-
event -
payload
Emits an event to the instance: calls all event listeners subscribed to this event, or the 'any' event.
Parameters:
-
eventStringEvent
-
payloadAn object passed as parameter to all event listeners.
getEstimatedTime
()
Number
Returns the estimated time to load the resource. Can be overridden.
Returns:
The estimated time
load
-
onFinish -
onError -
onProgress
Called when the resource is needed to load.
Parameters:
-
onFinishFunctionhave to be called when the resource is finished
-
onErrorFunctionhave to be called when an error occurs
-
onProgressFunctionmay be called when the progress changes (value in percent)
off
-
event -
listener
Unsubscribes from an event.
Parameters:
-
eventStringEvent
-
listenerFunctionEvent listener
on
-
event -
listener
Subscribes to an event. The event handler will be called with this instance as context.
Parameters:
-
eventStringThe event to subscribe
-
listenerFunctionEvent listener
Events
any
Emitted when any event is emitted. The parameters are the event and the payload.
