Class: ProcessQueue

Phaser.Structs. ProcessQueue

A Process Queue maintains three internal lists.

The pending list is a selection of items which are due to be made 'active' in the next update. The active list is a selection of items which are considered active and should be updated. The destroy list is a selection of items that were active and are awaiting being destroyed in the next update.

When new items are added to a Process Queue they are put in the pending list, rather than being added immediately the active list. Equally, items that are removed are put into the destroy list, rather than being destroyed immediately. This allows the Process Queue to carefully process each item at a specific, fixed time, rather than at the time of the request from the API.


new ProcessQueue()

Since: 3.0.0
Source: src/structs/ProcessQueue.js (Line 11)

Extends

Members


<readonly> length :integer

The number of entries in the active list.

Type:
  • integer
Since: 3.20.0
Source: src/structs/ProcessQueue.js (Line 251)

Methods


add(item)

Adds a new item to the Process Queue.

The item is added to the pending list and made active in the next update.

Parameters:
Name Type Description
item *

The item to add to the queue.

Since: 3.0.0
Source: src/structs/ProcessQueue.js (Line 93)
Returns:

The item that was added.

Type
*

addListener(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 111)
Returns:

this.

Type
Phaser.Events.EventEmitter

destroy()

Immediately destroys this process queue, clearing all of its internal arrays and resetting the process totals.

Since: 3.0.0
Overrides:
Source: src/structs/ProcessQueue.js (Line 268)

emit(event [, args])

Calls each of the listeners registered for a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

args * <optional>
<repeatable>

Additional arguments that will be passed to the event handler.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 86)
Returns:

true if the event had listeners, else false.

Type
boolean

eventNames()

Return an array listing the events for which the emitter has registered listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 55)
Returns:
Type
array

getActive()

Returns the current list of active items.

This method returns a reference to the active list array, not a copy of it. Therefore, be careful to not modify this array outside of the ProcessQueue.

Since: 3.0.0
Source: src/structs/ProcessQueue.js (Line 233)
Returns:

A list of active items.

Type
Array.<*>

listenerCount(event)

Return the number of listeners listening to a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 75)
Returns:

The number of listeners.

Type
number

listeners(event)

Return the listeners registered for a given event.

Parameters:
Name Type Description
event string | symbol

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 64)
Returns:

The registered listeners.

Type
array

off(event [, fn] [, context] [, once])

Remove the listeners of a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 151)
Returns:

this.

Type
Phaser.Events.EventEmitter

on(event, fn [, context])

Add a listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 98)
Returns:

this.

Type
Phaser.Events.EventEmitter

once(event, fn [, context])

Add a one-time listener for a given event.

Parameters:
Name Type Argument Default Description
event string | symbol

The event name.

fn function

The listener function.

context * <optional>
this

The context to invoke the listener with.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 124)
Returns:

this.

Type
Phaser.Events.EventEmitter

remove(item)

Removes an item from the Process Queue.

The item is added to the pending destroy and fully removed in the next update.

Parameters:
Name Type Description
item *

The item to be removed from the queue.

Since: 3.0.0
Source: src/structs/ProcessQueue.js (Line 117)
Returns:

The item that was removed.

Type
*

removeAll()

Removes all active items from this Process Queue.

All the items are marked as 'pending destroy' and fully removed in the next update.

Since: 3.20.0
Source: src/structs/ProcessQueue.js (Line 141)
Returns:

This Process Queue object.

Type
Phaser.Structs.ProcessQueue

removeAllListeners( [event])

Remove all listeners, or those of the specified event.

Parameters:
Name Type Argument Description
event string | symbol <optional>

The event name.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 165)
Returns:

this.

Type
Phaser.Events.EventEmitter

removeListener(event [, fn] [, context] [, once])

Remove the listeners of a given event.

Parameters:
Name Type Argument Description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 137)
Returns:

this.

Type
Phaser.Events.EventEmitter

shutdown()

Removes all listeners.

Since: 3.0.0
Inherited From:
Source: src/events/EventEmitter.js (Line 31)

update()

Update this queue. First it will process any items awaiting destruction, and remove them.

Then it will check to see if there are any items pending insertion, and move them to an active state. Finally, it will return a list of active items for further processing.

Since: 3.0.0
Source: src/structs/ProcessQueue.js (Line 167)
Returns:

A list of active items.

Type
Array.<*>