EventHub 1.0.0-CI-20190817-064108
See the version list below for details.
dotnet add package EventHub --version 1.0.0-CI-20190817-064108
NuGet\Install-Package EventHub -Version 1.0.0-CI-20190817-064108
<PackageReference Include="EventHub" Version="1.0.0-CI-20190817-064108" />
paket add EventHub --version 1.0.0-CI-20190817-064108
#r "nuget: EventHub, 1.0.0-CI-20190817-064108"
// Install EventHub as a Cake Addin #addin nuget:?package=EventHub&version=1.0.0-CI-20190817-064108&prerelease // Install EventHub as a Cake Tool #tool nuget:?package=EventHub&version=1.0.0-CI-20190817-064108&prerelease
EventHub
This project is inspired by EventBus for Android & Java. you can checkout their repository at this link.
This is a project that implements the Pub/Sub model in a decoupled architecture. It can be especially useful in situations where entities have there own life-cycle.
This architecture can be used to develop applications for Xamarin.Forms, Xamarin.Android, Xamarin.iOS. It helps in seamless communication between various parts of the respective application models.
Features
- Attribute based API: Put the [EventSubscriber] attribute to your subscriber methods to mark it as a handler.
- Good performance: It is optimized to dispatch events as soon as they posted.
- Asynchronous event Delivery & Execution: All the event executions and delivery are asynchronous.
- Event & Subscriber inheritance: In EventHub, the object oriented paradigm apply to event and subscriber classes. Let's say event class A is the superclass of B. Posted events of type B will also be posted to subscribers interested in A. Similarly the inheritance of subscriber classes are considered.
- Main thread delivery: Using platform specific main thread invocation methods, you can also deliver UI changes to the application.
- No 3rd party dependency: This is no Xamarin binding, thus no 3rd party dependency or binding difficulties.
Add EventHub to your Project
The project is still in pre-release mode, but will be releasing a stable version soon.
Steps to use EventHub
Define classes for evevnts
public class Event { /* Additional fields if needed */ }
Prepare subscribers: Declare and add attribute to your subscribing method
[EventSubscriber] public void Subscriber(Event event) {/*Do Something*/}
Register and deregister your subscriber according to your lifecycle.
For Xamarin.Android :
protected override void OnAppearing() { base.OnAppearing(); EventHub.Instance.Register(this); } protected override void OnDisappearing() { base.OnDisappearing(); EventHub.Instance.Deregister(this); }
For Xamarin.iOS :
public override void WillEnterForeground(UIApplication application) { EventHub.Instance.Register(this); } public override void DidEnterBackground(UIApplication application) { EventHub.Instance.Deregister(this); }
For Xamarin.Forms :
protected override void OnAppearing() { base.OnAppearing(); EventHub.Instance.Register(this); } protected override void OnDisappearing() { base.OnDisappearing(); EventHub.Instance.Deregister(this); }
Post Events.
EventHub.Instance.Post(new Event());
Main thread delivery
- Xamarin.Android
[EventSubscriber] public void OnEvent(string s) { new Handler(Looper.MainLooper).Post(() => { /* Do whatever you want on application UI thread*/ }); }
- Xamarin.iOS
[EventSubscriber] public void OnEvent(string s) { InvokeOnMainThread(()=> { /* Do whatever you want on application UI thread*/ }); }
- Xamarin.Forms
[EventSubscriber] public void OnEvent(string s) { Device.BeginInvokeOnMainThread(()=> { /* Do whatever you want on application UI thread*/ }); }
Future Scope
- Build time subscriber method template cache, so that run time performance stays unaffected.
- Assign batches for every event posted.
- Cancellation will depend on execution state of the batch.
- Priority based event posting.
License
EventHub binaries and source code can be used according to the Apache License 2.0.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EventHub:
Package | Downloads |
---|---|
EventHub.Microsoft.Extensions.DependencyInjection
EventHub.Microsoft.Extensions.DependencyInjection is a NuGet package that simplifies the integration of the EventHub library with Microsoft.Extensions.DependencyInjection in .NET applications. This package enables seamless dependency injection of EventHub services, allowing you to efficiently manage and dispatch signals (events) within your application. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 1,804 | 8/19/2019 |
1.0.0-CI-20190818-153708 | 807 | 8/18/2019 |
1.0.0-CI-20190817-064108 | 835 | 8/17/2019 |