NGL@1.0.0-beta.7 Home Manual Reference Source Gallery
import Counter from 'ngl/src/utils/counter.js'
public class | source

Counter

Counter class for keeping track of counts

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

The count

public

Method Summary

Public Methods
public

Change the count

public

Set the count to zero

public

Decrements the count by one.

public
public

Increments the count by one.

public

listen(counter: Counter): undefined

Listen to another counter object and change this count by the same amount

public

onZeroOnce(callback: Function, context: Object): undefined

Invole the callback function once, when the count becomes zero

public

Stop listening to the other counter object

Public Constructors

public constructor() source

Public Members

public count: Integer source

The count

public signals source

Public Methods

public change(delta: Integer): undefined source

Change the count

Params:

NameTypeAttributeDescription
delta Integer

count change

Return:

undefined

public clear(): undefined source

Set the count to zero

Return:

undefined

public decrement(): undefined source

Decrements the count by one.

Return:

undefined

public dispose() source

public increment(): undefined source

Increments the count by one.

Return:

undefined

public listen(counter: Counter): undefined source

Listen to another counter object and change this count by the same amount

Params:

NameTypeAttributeDescription
counter Counter

the counter object to listen to

Return:

undefined

public onZeroOnce(callback: Function, context: Object): undefined source

Invole the callback function once, when the count becomes zero

Params:

NameTypeAttributeDescription
callback Function

the callback function

context Object

the context for the callback function

Return:

undefined

public unlisten(counter: Counter): undefined source

Stop listening to the other counter object

Params:

NameTypeAttributeDescription
counter Counter

the counter object to stop listening to

Return:

undefined