{"id":16175720,"url":"https://github.com/osiris-team/easy-java-events","last_synced_at":"2025-03-19T00:31:26.058Z","repository":{"id":110532935,"uuid":"471044351","full_name":"Osiris-Team/Easy-Java-Events","owner":"Osiris-Team","description":"EJE provides accessible methods for handling events/actions/listeners.","archived":false,"fork":false,"pushed_at":"2023-10-06T12:00:42.000Z","size":74,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T13:31:14.574Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Osiris-Team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-17T15:50:38.000Z","updated_at":"2022-08-23T14:20:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc926597-118f-4b1c-8717-ca08cfc12008","html_url":"https://github.com/Osiris-Team/Easy-Java-Events","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2FEasy-Java-Events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2FEasy-Java-Events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2FEasy-Java-Events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Osiris-Team%2FEasy-Java-Events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Osiris-Team","download_url":"https://codeload.github.com/Osiris-Team/Easy-Java-Events/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955697,"owners_count":20374374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T04:45:37.851Z","updated_at":"2025-03-19T00:31:25.761Z","avatar_url":"https://github.com/Osiris-Team.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy-Java-Events\nEJE provides accessible methods for handling events/actions/listeners.\nAdd this as dependency to your project via\n[Maven/Gradle/Sbt/Leinigen](https://jitpack.io/#Osiris-Team/Easy-Java-Events/LATEST) (requires Java 8 or higher).\n\n#### Learn the basics in 10 seconds:\n```java\nEvent\u003cInteger\u003e onValueChanged = new Event\u003c\u003e();\n\nonValueChanged.addAction(value -\u003e { \n    System.out.println(\"New value: \"+value); \n}); \n\nonValueChanged.execute(10); // Prints out \"New value: 10\"\nonValueChanged.execute(5); // Prints out \"New value: 5\"\n```\n\n#### Learn everything in 5 minutes:\n```java\nclass EventTest {\n    @Test\n    void example() {\n        Event\u003cInteger\u003e onValueChanged = new Event\u003c\u003e();\n        Action\u003cInteger\u003e myAction = onValueChanged.addAction(value -\u003e { // Stays in memory and gets executed every time.\n            System.out.println(\"New value: \"+value);\n            // You can throw exceptions in here\n        }, Exception::printStackTrace); // and catch them here.\n\n        onValueChanged.execute(10); // Prints out \"New value: 10\"\n        onValueChanged.execute(5); // Prints out \"New value: 5\"\n\n        // One time actions that only get executed once, are also supported:\n        onValueChanged.addOneTimeAction(value -\u003e {\n            System.out.println(\"New value: \"+value+\" bye!\");\n        }, Exception::printStackTrace);\n\n        onValueChanged.execute(7); // Prints out \"New value: 7\" and \"New value: 7 bye!\"\n\n        // If more and more actions get added over time\n        // you must remove unused actions. There are some util methods for this case.\n        // First we create a new action with additional params: isOneTime=false and object=null.\n        Action\u003cInteger\u003e actionToRemove = onValueChanged.addAction((action, value) -\u003e {\n            System.out.println(\"New value: \"+value+\", but I will be gone soon :/\");\n        }, Exception::printStackTrace, false, null);\n\n        // Then we initialise the cleaner thread for this event, which checks\n        // its actions list every 100ms for actions that\n        // fulfill the condition \"object != null\" and removes those.\n        onValueChanged.initCleaner(100, object -\u003e object != null, Exception::printStackTrace);\n\n        // Once we want to remove the action, we simply give it an object that is not null.\n        // The cleaner then removes it in the next check.\n        actionToRemove.object = new Object(); // Note that you can store any type of object here.\n    }\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosiris-team%2Feasy-java-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosiris-team%2Feasy-java-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosiris-team%2Feasy-java-events/lists"}