Coder Social home page Coder Social logo

johnshiozo / attendance Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vialdevelopment/attendance

1.0 0.0 0.0 93 KB

An event handler, made as small as possible. I tried to eliminate anything and everything that wasn't important.

Java 100.00%

attendance's Introduction

Attendance

Attendance is a small and (hopefully) decently quick event handler that supports priority and other fun things

It's made to be as small and simple as I can get it.

This was made for fun, and although I probably will use it in a lot of my projects, I cannot recommend using it in any projects. It's not exactly made for commercial use and likely has a lot of issues.

Usage

import io.github.vialdevelopment.attendance.attender.Attend;
import io.github.vialdevelopment.attendance.attender.Attender;
import io.github.vialdevelopment.attendance.attender.EventManager;

public class Main {

    private static EventManager manager = new EventManager();

    public static void main(String[] args) {
        // registers the attenders and adds em to the list
        final Main main = new Main();
        manager.registerAttender(main);
        
        // Sets them as attending
        manager.setAttending(main, true);
        // Dispatches the event
        manager.dispatch(new Event());
    }

    // When this is ran, these should print out 3, 2, 1, then 0 in that order because of the priority

    @Attend(priority = 3)
    public Attender<Event> event3 = new Attender<>(Event.class, event -> {
        System.out.println("3");
    });

    @Attend(priority = 1)
    public Attender<Event> event1 = new Attender<>(Event.class, event -> {
        System.out.println("1");
    });

    @Attend(priority = 2)
    public Attender<Event> event2 = new Attender<>(Event.class, event -> {
        System.out.println("2");
    });

    @Attend(priority = 0)
    public Attender<Event> event0 = new Attender<>(Event.class, event -> {
        System.out.println("0");
    });

    static class Event {
    }
}

attendance's People

Contributors

cuhnt avatar

Stargazers

 avatar

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.