TimedObserver Atom feed

An abstract observer class which instances can be used to periodically check some value and trigger a callback when the value has changed. The frequency is in seconds.

A TimedObserver object will try to check some value using the getValue() instance method which isn't defined in this class. You must use the concrete implementations of TimedObserver like Form.Observer or Form.Element.Observer. The former serializes a form and triggers when the result has changed, while the latter simply triggers when the value of a certain form control changes.

Using TimedObserver implementations is straightforward; simply instantiate them with appropriate arguments. For example:

new Form.Element.Observer(
  0.2,  // 200 milliseconds
  function(el, value){
    alert('The form control has changed value to: ' + value)

Now that we have instantiated an object, it will check the value of the form control every 0.2 seconds and alert us of any change. While it is useless to alert the user of his own input (like in the example), we could be doing something useful like updating a certain part of the UI or informing the application on server of stuff happening (over Ajax).

The callback function is always called with 2 arguments: the element given when the observer instance was made and the actual value that has changed and caused the callback to be triggered in the first place.



new Form.Element.Observer(element, frequency, callback)

A timed observer for a specific form control.


new Form.Observer(element, frequency, callback)

A timed observer that triggers when any value changes within the form.