Skip to content

Simple event system implementation like Java EventBus.

License

Notifications You must be signed in to change notification settings

949886/EventBus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EventBus

Simple implementation just like java EventBus.

private void Start()
{
    EventBus.Default.Register(this);
}

private void OnDestroy()
{
    EventBus.Default.Unregister(this);
}

[Subscribe(ThreadMode.MAIN)]
private void HandleEvent(ShootMessage message)
{
    /* do something when shooting on main thread */
}

[Subscribe]
private void HandleEventSync(ShootMessage message)
{
    /* do something when shooting in the same thread */
}

[Subscribe(ThreadMode.BACKGROUND)]
private void HandleEventAsync(ShootMessage message)
{
    /* do something when shooting on background thread */
}

public void Update()
{
    // Trigger event.
    EventBus.Default.Post(new ShootMessage(/*args*/));
}

[Subscribe(ThreadMode.BACKGROUND)]
private void HandleEventAsync(ShootMessage message)
{
    /* do something when shooting */
}

public void Update()
{
    // Triger event.
    EventBus.Default.Post(new ShootMessage(/*args*/));
}

About

Simple event system implementation like Java EventBus.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages