Note: This module is not part of the public API, and is subject to change.

Module: j5e/withinable

Description

For emitting events when value is within a certain range

Requires


Class: Withinable

Constructor

new Withinable()

Methods

Withinable.within

Fire a callback when the value is within a certain range

withinable.within(range, unit, callback);

Parameters

Name
Type
Description
range
(required)
Array.<number>

Description:
The upper and lower ends of the range to watch

unit
(required)
string

Description:
The property to test

callback
(required)
function

Description:
A callback to run when the event is fired.


Withinable.on

Create an event listener

withinable.on(event, listener);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event to listen for

listener
(required)
function

Description:
A callback to run when the event is fired.


Withinable.removeListener

Remove an event listener

withinable.removeListener(event, listener);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event that we are removing a listener from

listener
(required)
function

Description:
The callback that we are removing


Withinable.emit

Note: This method is not part of the public API, and is subject to change.

Emit an event

withinable.emit(event);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event to emit


Withinable.once

Create an event listener that will only fire one time.

withinable.once(event, listener);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event to listen for

listener
(required)
function

Description:
A callback to run when the event is fired.