Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeroflag/java8-announcer
A simple Smalltalk Announcers like library for Java 8
https://github.com/zeroflag/java8-announcer
Last synced: 15 days ago
JSON representation
A simple Smalltalk Announcers like library for Java 8
- Host: GitHub
- URL: https://github.com/zeroflag/java8-announcer
- Owner: zeroflag
- Created: 2015-05-07T14:13:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-08T10:01:19.000Z (over 8 years ago)
- Last Synced: 2024-10-31T06:41:47.582Z (2 months ago)
- Language: Java
- Size: 52.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/zeroflag/java8-announcer.svg?branch=master)](https://travis-ci.org/zeroflag/java8-announcer)
```java
Announcer announcer = new Announcer();// simple lambda subscriptions
announcer.subscribe(String.class, str -> System.out.println("received string: " + str));
announcer.subscribe(Number.class, n -> System.out.println("received number: " + n));
announcer.subscribe(Integer.class, i -> System.out.println(i*2));// announce events
announcer.announce("test string");
announcer.announce(3);// custom listener and event objects
MyListener listener = new MyListener();
announcer.subscribe(AnEvent.class, listener::onTestEvent);
announcer.announce(new AnEvent("some payload"));
announcer.announce(new ASubEvent("some payload"));// unsubscribe
Subscription subscription = announcer.subscribe(AnEvent.class, (evt) -> {})
announcer.unsubscribe(subscription);
```