Skip to content

msteinbeck/sig4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sig4j

Maven Central

Sig4j is a Java library for Qt like signals and slots which uses the FunctionalInterface Annotation introduced with Java 8. This Annotation allows sig4j to connect functions and lambdas to signals without much effort .

Quickstart

The following code snippet gives a short example:

import com.github.msteinbeck.sig4.ConnectionType;
import com.github.msteinbeck.sig4j.Signal1;

public class Quickstart {
    private final Signal1<String> signal = new Signal1<>();
    
    private void print(final String string) {
        System.out.println(string);
    }

    public static void main(final String[] args) {
        Quickstart q = new Quickstart();
        q.signal.connect(q::print);
        q.signal.emit("hellow world!");
    }
}

Sig4j supports the following connection types:

  • Direct: A slot is actuated within the thread context of the emitter.
  • Queued: A slot is actuated by a global worker thread.
  • Dispatched: A slot is actuated by a custom dispatcher.
  • JavaFX: A slot is actuated by the JavaFX dispatcher thread.
  • Swing: A slot is actuated by the Swing dispatcher thread.

Have a look at examples.

About

Java library for Qt like signals and slots

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages