Observable

Observable class.

Allows to extend any struct with ability to Fire events and ability to listen for any events.

package

Default

Methods

Fires event.

fire() 

Executes callback functions and passes data to them.

Unsubscribes from an event.

off(string $event, callable $callback) 

Use the callback function that you used when calling "on".

Arguments

$event

string

Event name

$callback

callable

Callback function that was used when calling "on"

Adds listener for an event.

on(string $event, callable $callback) 

Arguments

$event

string

Event name

$callback

callable

function to be called when an event is "fire"

Properties

List of callbacks splitted by Event name.

events : array
var

Type(s)

array

Stub arguments to be passed to callback.

stub : array

Requires to avoid "Missing numbers of arguments" if callback function requires args, that were not passed to fire()

var

Type(s)

array