Skip to main content
Version: 2.0.0

Haply::Inverse::Unity::EventDispatcher

A thread-safe class which holds a queue with actions to execute on the next Update() method. More...

Inherits from Haply.Inverse.Unity.Singleton< EventDispatcher >, MonoBehaviour

Public Functions

Name
voidAwake()
voidUpdate()
voidEnqueue(IEnumerator action)
Locks the queue and adds the IEnumerator to the queue.
voidEnqueue(Action action)
Locks the queue and adds the Action to the queue.
voidEnqueue(UnityEvent action)
Locks the queue and adds the Action to the queue.
voidEnqueue< T >(Action< T > action, T arg)
Locks the queue and adds the Action (with a parameter T) to the queue.
voidEnqueue< T >(UnityEvent< T > action, T arg)
Locks the queue and adds the Action (with a parameter T) to the queue.
voidEnqueue< T0, T1 >(Action< T0, T1 > action, T0 arg0, T1 arg1)
Locks the queue and adds the Action (with two parameters T0 and T1) to the queue.
voidEnqueue< T0, T1 >(UnityEvent< T0, T1 > action, T0 arg0, T1 arg1)
Locks the queue and adds the Action (with two parameters T0 and T1) to the queue.
TaskEnqueueAsync(Action action)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
TaskEnqueueAsync(UnityEvent action)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
TaskEnqueueAsync< T >(Action< T > action, T arg)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
TaskEnqueueAsync< T >(UnityEvent< T > action, T arg)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.

Public Properties

Name
boolIsMainThread

Additional inherited members

Public Functions inherited from Haply.Inverse.Unity.Singleton< EventDispatcher >

Name
voidInitializeInstance()
Initializes the singleton instance.
boolExists()

Protected Functions inherited from Haply.Inverse.Unity.Singleton< EventDispatcher >

Name
virtual voidOnDestroy()
virtual voidOnApplicationQuit()

Public Properties inherited from Haply.Inverse.Unity.Singleton< EventDispatcher >

Name
TInstance
Gets the instance of the singleton class.

Detailed Description

class Haply::Inverse::Unity::EventDispatcher;

A thread-safe class which holds a queue with actions to execute on the next Update() method.

It can be used to make calls to the main thread for things such as UI Manipulation in Unity. It was developed for use in combination with the Firebase Unity plugin, which uses separate threads for event handling

Pim de Witte (pimdewitte.com) and contributors, 2014

Public Functions Documentation

function Awake

void Awake()

function Update

void Update()

function Enqueue

void Enqueue(
IEnumerator action
)

Locks the queue and adds the IEnumerator to the queue.

Parameters:

  • action IEnumerator function that will be executed from the main thread.

function Enqueue

void Enqueue(
Action action
)

Locks the queue and adds the Action to the queue.

Parameters:

  • action function that will be executed from the main thread.

function Enqueue

void Enqueue(
UnityEvent action
)

Locks the queue and adds the Action to the queue.

Parameters:

  • action function that will be executed from the main thread.

function Enqueue< T >

void Enqueue< T >(
Action< T > action,
T arg
)

Locks the queue and adds the Action (with a parameter T) to the queue.

Parameters:

  • action function (requires parameter of type T) that will be executed from the main thread.
  • arg parameter of type T to pass to action.

function Enqueue< T >

void Enqueue< T >(
UnityEvent< T > action,
T arg
)

Locks the queue and adds the Action (with a parameter T) to the queue.

Parameters:

  • action function (requires parameter of type T) that will be executed from the main thread.
  • arg parameter of type T to pass to action.

function Enqueue< T0, T1 >

void Enqueue< T0, T1 >(
Action< T0, T1 > action,
T0 arg0,
T1 arg1
)

Locks the queue and adds the Action (with two parameters T0 and T1) to the queue.

Parameters:

  • action function (requires parameters of type T0 and T1) that will be executed from the main thread.
  • arg0 parameter of type T0 to pass to action.
  • arg1 parameter of type T1 to pass to action.

function Enqueue< T0, T1 >

void Enqueue< T0, T1 >(
UnityEvent< T0, T1 > action,
T0 arg0,
T1 arg1
)

Locks the queue and adds the Action (with two parameters T0 and T1) to the queue.

Parameters:

  • action function (requires parameters of type T0 and T1) that will be executed from the main thread.
  • arg0 parameter of type T0 to pass to action.
  • arg1 parameter of type T1 to pass to action.

function EnqueueAsync

Task EnqueueAsync(
Action action
)

Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.

Parameters:

  • action function that will be executed from the main thread.

Return: A Task that can be awaited until the action completes

function EnqueueAsync

Task EnqueueAsync(
UnityEvent action
)

Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.

Parameters:

  • action function that will be executed from the main thread.

Return: A Task that can be awaited until the action completes

function EnqueueAsync< T >

Task EnqueueAsync< T >(
Action< T > action,
T arg
)

Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.

Parameters:

  • action function that will be executed from the main thread.
  • arg parameter of type T to pass to action.

Return: A Task that can be awaited until the action completes

function EnqueueAsync< T >

Task EnqueueAsync< T >(
UnityEvent< T > action,
T arg
)

Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.

Parameters:

  • action function that will be executed from the main thread.
  • arg parameter of type T to pass to action.

Return: A Task that can be awaited until the action completes

Public Property Documentation

property IsMainThread

static bool IsMainThread;