Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

Install via UPM

Add to Unity Package Manager using this URL

https://www.pkglnk.dev/wlgys8-eventbus.git

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **EventBus** to your Unity project via Package Manager:

1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/wlgys8-eventbus.git
```

[![pkglnk](https://www.pkglnk.dev/badge/wlgys8-eventbus.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/wlgys8-eventbus)

Dependencies (1)

README

EventBus

A simple event subscribe & post library for Unity

Quick Start

Install

By unity package manager:

"com.ms.eventbus":"https://github.com/wlgys8/EventBus.git",

Usage

1. Non-parameterized Event


var bus = new EventBus();

System.Action callback = ()=>{

}
//subscribe the event
bus.On(callback);

//callback will be invoked one time and remove self.
bus.Once(()=>{
});

//post a event
bus.Post();

//unsubscribe callback
bus.Off(callback);

2. Parameterized Event


var bus = new EventBus();

//subscribe int event
bus.On<int>((int number)=>{

})

//only callback with int could receive the post.
bus.Post<int>(1024);

3. EventBus with EventType


//eventbus with string as EventType
var bus = new EventBus<string>();

bus.On("open",()=>{

});

bus.On("close",()=>{

});

bus.On<float>("tick",(time)=>{

});

bus.On("any other event name",()=>{

});


//only the callbacks subscribed on "open" could receive the post
bus.Post("open");

bus.Post<float>("tick",Time.time);

Comments

No comments yet. Be the first!