Looking at the event docs it described many ways to subscribe to different types of events.
But now i want to regularly publish an event from another thread outside the game loop and have a nifty element listen to these events. Any way to do this?
I think i might be able to use a second event bus as described here:
I just thought the one used in nifty would expose an interface for publishing custom events…
You must use a synchronization mechanism. The best one I found is using the application.enqueue(Callable<>).
@SomeNiftySubscription
public void hideEvent() {
application.enqueue( new Callable<Void>(){
public Void call() throws Exception {
element.hide();
return null;
}
}
}
Yeah, it doesn’t matter how many event buses you use if they are running on the wrong thread.
Best to use app.enqueue() as mentioned.