Class: Dismissable

Dismissable

Abstract class. Instances of extended classes can be used to keep track of the uses of a certain resources that can then be trashed after a timeout once it is no more used by anyone.

new Dismissable()

This constructor simply calls the initTouches method. This abstract class is supposed to be extended using Inheritance extension. It can be either light extended or fully extended. When light extension is performed the initDispatcher method should be called in the extended class constructor.
For this class to properly work the clean method that releases the resources needs to be implemented.

Method Summary

clean
Abstract method that needs to be implemented to clean the used resources.
dismiss
Method to be called to declare that this instance is not in use anymore by some component.
initTouches
Method to be called to initialize the use of the Dismissable features.
touch
Method to be called to declare that this instance is in use by some component.

Method Detail

<abstract> clean()

Abstract method that needs to be implemented to clean the used resources. This method is called internally after a timeout when all of the uses ( i.e. calls to touch ) were dismissed (using dismiss).

dismiss()

Method to be called to declare that this instance is not in use anymore by some component. This method should only be called once per each previous touch call or the resource may be dismissed while some piece of code still needs it.
See:
  • dismiss

<protected> initTouches(timeout)

Method to be called to initialize the use of the Dismissable features. If not called touch and dismiss calls will fail. Ideally this method should be called in the constructor.
Parameters:
Name Type Description
timeout Number the time in ms to wait after all the uses were dismissed before actually clean the resources. If a new call to touch is performed before the timeout is expired the clean is postponed until the touches count is back to 0 again. If not specified 5000 (5 seconds) is used.

touch()

Method to be called to declare that this instance is in use by some component. Per each touch call a {@link dismiss} call should be called at some point or the resources will never be released.
See:
  • dismiss