Giter VIP home page Giter VIP logo

eventlibrary's Introduction

EventLibrary

A bloat-free library for dispatching and receiving events.

Features

EventLibrary contains the following features:

  • dispatch events (synchronously and asynchronously)
  • register (anonymous) listeners for events
  • provide your custom implementations to process events however you want

Dependencies

Gradle

repositories {
    maven {
        name = "GitHubPackages"
        url = uri("https://maven.pkg.github.com/SteveOberst/EventLibrary")
        credentials {
            username = project.findProperty("gpr.user") ?: System.getenv().get("GITHUB_USERNAME")
            password = project.findProperty("gpr.key") ?: System.getenv().get("GITHUB_TOKEN")
        }
    }
}

dependencies {
    implementation group: "net.sxlver.eventlibrary", name: "core", version: "<latest>"
}

latest

Initialization

No need for initialization! The Framework is mostly based off of static access, so no need to store any references.

Event Dispatching

final MyEvent event = new MyEvent();
final IEventResult<MyEvent> result = EventLibrary.dispatchEvent(event);

Event Subscribers

public class MyListener {
    @EventSubscriber
    public IListenerExecutionResult<MyEvent> onEvent(final MyEvent event) {
        //...
        return ListenerExecutionResult.success(event);
    }
}

public class Main {
    public static void main(String[] args) {
        EventLibrary.registerListener(new MyListener());
    }
}

Anonymous Handlers

final IEventHandler<MyEvent> handler = EventLibrary.registerListener(event -> {
    //...
    return ListenerExecutionResult.success(event);
, MyEvent.class})

Examples and docs

To get started with the framework make sure to checkout the Examples and Docs

License

Released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.