Skip to content

Commit 8996277

Browse files
one global onCompleted object
1 parent dc15e2b commit 8996277

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rxjava-core/src/main/java/rx/Notification.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class Notification<T> {
2626
private final Throwable throwable;
2727
private final T value;
2828

29+
private static final Notification<Void> ON_COMPLETED = new Notification<Void>(Kind.OnCompleted, null, null);
30+
2931
public static <T> Notification<T> createOnNext(T t) {
3032
return new Notification<T>(Kind.OnNext, t, null);
3133
}
@@ -34,12 +36,14 @@ public static <T> Notification<T> createOnError(Throwable e) {
3436
return new Notification<T>(Kind.OnError, null, e);
3537
}
3638

39+
@SuppressWarnings("unchecked")
3740
public static <T> Notification<T> createOnCompleted() {
38-
return new Notification<T>(Kind.OnCompleted, null, null);
41+
return (Notification<T>) ON_COMPLETED;
3942
}
4043

44+
@SuppressWarnings("unchecked")
4145
public static <T> Notification<T> createOnCompleted(Class<T> type) {
42-
return new Notification<T>(Kind.OnCompleted, null, null);
46+
return (Notification<T>) ON_COMPLETED;
4347
}
4448

4549
private Notification(Kind kind, T value, Throwable e) {

0 commit comments

Comments
 (0)