Namespace: Events

Canadarm. Events

pseudo namespace to help with documentation.
Source:

Methods

<static> attempt(fn, context, Additional)

Execute the given function and logs any errors thrown.
Parameters:
Name Type Description
fn function The function to wrap.
context object The context to execute the function in. Defaults to this.
Additional arguments passed to the function.
Source:
Returns:
The result of passed function fn.
Example
  Canadarm.attempt(myFunction); // immediately executed

<static> localAttempt(fn, settings, context, Additional)

Execute the given function and logs any errors thrown.
Parameters:
Name Type Description
fn function The function to wrap.
settings object Override default Appenders and Handlers here, by default will do nothing if not passed.
context object The context to execute the function in. Defaults to this.
Additional arguments passed to the function.
Source:
Returns:
The result of passed function fn.
Example
  Canadarm.localAttempt(myFunction, settingsHash); // immediately executed

<static> localWatch(fn, settings, context)

Return wrapped function which when called, logs any errors thrown. Should only be used when needing to have custom, localized error handling.
Parameters:
Name Type Description
fn function The function to wrap
settings object Override default Appenders and Handlers here, by default will do nothing if not passed.
context object The context to execute the function in. Defaults to this.
Source:
Returns:
A wrapped function with the original function a property of the wrapped function called _wrapped.
Example
  mySpecificFunction = Canadarm.localWatch(function realFunction() {
     // The parts that do the actual work of your application.
   },
   {
     appenders: [Canadarm.Appender.standardLogAppender],
     handlers: [Canadarm.Handler.beaconHandler('http://path-to-my-logger.somesite.com/more-path/')]
   }
 )

<private, static> setUpEventListening()

Internal method for setting up event listening within this library. This works by overriding the default `addEventListener`/`attachEvent` and the `removeEventListener`/`detachEvent`. The default add and remove of events is overridden and every function that is attached as a listener is wrapped in a `Canadarm.watch` call. For removing of the event the internals of the `Canadarm.watch` call keep track of the function made and always return a new function for watching or the one that is already watched. This allows the code between attaching and removing events to look nearly identical. It also has the added bonus of not doing extra work when accidentally watching an already watched function.
Source:

<static> watch(fn, context)

Return a wrapped function which when called, logs any errors thrown.
Parameters:
Name Type Description
fn function The function to wrap.
context Object The context to execute the function in. Defaults to this.
Source:
Returns:
A wrapped function with the original function a property of the wrapped function called _wrapped.
Example
  Canadarm.watch(myFunction);