Skip to content

Commit

Permalink
Merge pull request #816 from samuelgruetter/globalOnCompleted
Browse files Browse the repository at this point in the history
One global onCompleted object
  • Loading branch information
benjchristensen committed Feb 5, 2014
2 parents 6756be3 + 8996277 commit 64f20f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rxjava-core/src/main/java/rx/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Notification<T> {
private final Throwable throwable;
private final T value;

private static final Notification<Void> ON_COMPLETED = new Notification<Void>(Kind.OnCompleted, null, null);

public static <T> Notification<T> createOnNext(T t) {
return new Notification<T>(Kind.OnNext, t, null);
}
Expand All @@ -34,12 +36,14 @@ public static <T> Notification<T> createOnError(Throwable e) {
return new Notification<T>(Kind.OnError, null, e);
}

@SuppressWarnings("unchecked")
public static <T> Notification<T> createOnCompleted() {
return new Notification<T>(Kind.OnCompleted, null, null);
return (Notification<T>) ON_COMPLETED;
}

@SuppressWarnings("unchecked")
public static <T> Notification<T> createOnCompleted(Class<T> type) {
return new Notification<T>(Kind.OnCompleted, null, null);
return (Notification<T>) ON_COMPLETED;
}

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

0 comments on commit 64f20f9

Please sign in to comment.