NGL@0.10.4 Home Manual Reference Source GalleryRepository
import Counter from 'ngl/src/utils/counter.js'
public class | source

Counter

Counter class for keeping track of counts

Member Summary

Public Members
public

The count

Method Summary

Public Methods
public

Change the count

public

Set the count to zero

public

Decrements the count by one.

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 Members

public count: number source

The count

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 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