This repository was archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
147 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
src/test/java/lol/hub/tinyeventbus/example/RefExample.java
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/test/java/lol/hub/tinyeventbus/example/ReferenceLambdaExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package lol.hub.tinyeventbus.example; | ||
|
||
import lol.hub.tinyeventbus.Bus; | ||
import lol.hub.tinyeventbus.Cancelable; | ||
import lol.hub.tinyeventbus.Sub; | ||
|
||
class ReferenceLambdaExample { | ||
|
||
Sub<TestEvent> consumer = Sub.of(TestEvent.class, TestEvent::cancel); | ||
|
||
void run() { | ||
|
||
// create bus instance | ||
Bus bus = new Bus(); | ||
|
||
bus.reg(consumer); | ||
final TestEvent evB = new TestEvent(); | ||
bus.pub(evB); | ||
|
||
System.out.println(evB.canceled); | ||
// prints: true | ||
|
||
} | ||
|
||
abstract static class CancelableEvent implements Cancelable { | ||
|
||
boolean canceled; | ||
|
||
CancelableEvent() { | ||
} | ||
|
||
public void cancel() { | ||
this.canceled = true; | ||
} | ||
|
||
@Override | ||
public boolean isCanceled() { | ||
return canceled; | ||
} | ||
|
||
} | ||
|
||
public static class TestEvent extends CancelableEvent { | ||
} | ||
|
||
static class Main { | ||
public static void main(String[] args) { | ||
new ReferenceLambdaExample().run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.