⁘ common.helpers

Callbacks

A Callbacks object is a very simple helper class that stores a list of functions into three distinct categories that can be called in registration order, with the ability to empty the list after it has been traversed.

It exists mostly to add semantic to the code and make it more readable in contexts that behave the like of a Promise.

go to → Members

Members

onAny :function

Registers an onAny function

onError :function

Registers an onError function

onSuccess :function

Registers an onSuccess function

Methods

Add(p_options)

Add a set of callbacks

Parameters:
Name Type Description
p_options object
Properties
Name Type Description
success function

onSuccess

error function

onError

any function

onAny

catch(p_fn)

Promise-looking OnError add.

Parameters:
Name Type Description
p_fn function

Clear()

Removes all callback handlers

finally(p_fn)

Promise-looking OnAny add.

Parameters:
Name Type Description
p_fn function

OnError(…args)

Call all error handlers with provided arguments, then all 'any'

Parameters:
Name Type Attributes Description
args any <repeatable>

OnSuccess(…args)

Call all success handlers with provided arguments, then all 'any'

Parameters:
Name Type Attributes Description
args any <repeatable>

then(p_fn)

Promise-looking OnSuccess add.

Parameters:
Name Type Description
p_fn function