Skip to content

Commit

Permalink
LiEventBus增加自定义push
Browse files Browse the repository at this point in the history
  • Loading branch information
leaderli committed Oct 20, 2024
1 parent 4152ffb commit 23534d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,23 @@ private static class DefaultBiConsumer<E extends LiEventObject<S>, S> implements
@Override
public void accept(SourceProvider<S> sourceProvider, ILiEventListener<E, S> listener) {
S source = sourceProvider.source;
if (source == null) {
listener.onNull();
return;
}
try {
if (source == null) {
listener.onNull();
return;
}
if (listener.before(source)) {
listener.listen(source);
listener.after(sourceProvider.liEventBusBehavior);
}
} catch (Throwable throwable) {
listener.onError(throwable);

try {

listener.onError(throwable);
} catch (Throwable ignore) {
//
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ void getPublisher() {
});
eventBus.registerListener(new TestLiEventListener3());

Assertions.assertThrows(RuntimeException.class, () -> {
Assertions.assertDoesNotThrow(() -> {
eventBus.push(new TestStringLiEventObject("456"));
Assertions.fail();
eventBus.push(new TestStringLiEventObject(null));
});
}

Expand Down

0 comments on commit 23534d5

Please sign in to comment.