Skip to content

Yet another clone of NSNotificationCenter in Java. But thread-safe and lock free (no synchronize...). And Tested.

License

Notifications You must be signed in to change notification settings

pbihler/NotificationCenter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notification Center for Java

This project provides a central event dispatch implementation, heavily inspired by NSNotificationCenter of Cocoa.

Simple usage Example

Observer

Observer o = new Observer(){
	public void receivedNotification(final Notification notification) {
		System.out.println("Received Notification: " + notification);
	}
}

/* Or with java 8:
 * Observer o = notification -> System.out.println("Received Notification: " + notification);
 */

...

DefaultNotificationCenter.instance().addObserver(o, Observee.MY_EVENT);

... (later)


DefaultNotificationCenter.instance().removeObserver(o);

Observee

String MY_EVENT = "MY_EVENT";

DefaultNotificationCenter.instance().postNotification(MY_EVENT);

Remarks

In its default implementation, it is designed thread safe and lock free.

To use it directly in your project you have to include the lombok.jar into your classpath.

If you do not want to include Project Lombok (and you considered this twice), run demlombok on the src folder and use the generated classes:

java -jar lombok.jar delombok src -d src-delomboked

License

This project is MIT licensed

About

Yet another clone of NSNotificationCenter in Java. But thread-safe and lock free (no synchronize...). And Tested.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages