StructureJS
0.15.2A class based utility library for building modular and scalable web platform applications. Features opt-in classes and utilities which provide a solid foundation and toolset to build your next project.
The ApplicationCacheService is a static class works with the window applicationCache object.
_appCache
ApplicationCache
private
static
A reference to the applicationCache property on the window object.
_eventDispatcher
EventDispatcher
private
static
A reference to the EventDispatcher object.
isEnabled
Boolean
public
static
The isEnabled property is used to keep track of the enabled state.
Default: false
_onCached
event
The resources listed in the manifest have been fully downloaded, and the application is now cached locally.
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
_onChecking
event
The browser is checking for an update, or is attempting to download the cache manifest for the first time. This is always the first event in the sequence.
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
_onDownloading
event
The browser has started to download the cache manifest, either for the first time or because changes have been detected.
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
_onError
event
An error occurred at some point - this could be caused by a number of things. This will always be the last event in the sequence.
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
_onNoUpdate
event
The cache manifest hadn't changed.
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
_onObsolete
event
The cache manifest file could not be found, indicating that the cache is no longer needed. The application cache is being deleted.
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
_onProgress
event
The browser had downloaded and cached an asset. This is fired once for every file that is downloaded (including the current page which is cached implicitly).
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
_onUpdateReady
event
The resources listed in the manifest have been newly re-downloaded, and the script can use swapCache() to switch to the new cache.
event
DOMApplicationCacheEvent
The native browser event from the DOMApplicationCache.
addEventListener
type
callback
scope
[priority=0]
Registers an event listener object with an ApplicationCacheService object so that the listener receives notification of an event.
type
String
The type of event.
callback
Function
The listener function that processes the event. This function must accept an Event object as its only parameter and must return nothing, as this example shows. @example function(event:Event):void
scope
Any
Binds the scope to a particular object (scope is basically what "this" refers to in your function). This can be very useful in JavaScript because scope isn't generally maintained.
[priority=0]
Int
optional
Influences the order in which the listeners are called. Listeners with lower priorities are called after ones with higher priorities.
ApplicationCacheService.addEventListener(ApplicationCacheEvent.UPDATE_READY, this._handlerMethod, this);
_handlerMethod(event) {
console.log(event.target + " sent the event.");
}
dispatchEvent
event
Dispatches an event within the ApplicationCacheService object.
event
ApplicationCacheEvent
The Event object that is dispatched into the event flow. You can create custom events, the only requirement is all events must extend the ApplicationCacheEvent.
let event = new ApplicationCacheEvent(ApplicationCacheEvent.UPDATE_READY);
ApplicationCacheService.dispatchEvent(event);
// Here is a common inline event being dispatched
ApplicationCacheService.dispatchEvent(new ApplicationCacheEvent(ApplicationCacheEvent.UPDATE_READY));
removeEventListener
type
callback
scope
Removes a specified listener from the ApplicationCacheService object.
type
String
The type of event.
callback
Function
The listener object to remove.
scope
Any
The scope of the listener object to be removed. This was added because it was need for the ApplicationCacheService class. To keep things consistent this parameter is required.
ApplicationCacheService.removeEventListener(ApplicationCacheEvent.UPDATE_READY, this._handlerMethod, this);
_handlerMethod(event) {
console.log(event.target + " sent the event.");
}