@@ -38,6 +38,7 @@ public class SubscriptionBuilder<T> {
38
38
private DataTransformer <T , Object > transformer ;
39
39
private Scheduler scheduler ;
40
40
private ErrorObserver errorObserver ;
41
+ private DataSubscriptionList dataSubscriptionList ;
41
42
// private boolean sync;
42
43
43
44
@@ -144,6 +145,10 @@ public DataSubscription observer(DataObserver<T> observer) {
144
145
weakObserver .setSubscription (subscription );
145
146
}
146
147
148
+ if (dataSubscriptionList != null ) {
149
+ dataSubscriptionList .add (subscription );
150
+ }
151
+
147
152
// TODO FIXME when an observer subscribes twice, it currently won't be added, but we return a new subscription
148
153
149
154
// Trivial observers do not have to be wrapped
@@ -165,15 +170,9 @@ public DataSubscription observer(DataObserver<T> observer) {
165
170
return subscription ;
166
171
}
167
172
168
- /**
169
- * Convenience for calling {@link #observer(DataObserver)} with adding the resulting {@link DataSubscription} to the
170
- * given {@link DataSubscriptionList}.
171
- */
172
- @ Beta
173
- public DataSubscription observer (DataObserver <T > observer , DataSubscriptionList dataSubscriptionList ) {
174
- DataSubscription dataSubscription = observer (observer );
175
- dataSubscriptionList .add (dataSubscription );
176
- return dataSubscription ;
173
+ public SubscriptionBuilder <T > dataSubscriptionList (DataSubscriptionList dataSubscriptionList ) {
174
+ this .dataSubscriptionList = dataSubscriptionList ;
175
+ return this ;
177
176
}
178
177
179
178
class ActionObserver implements DataObserver <T >, DelegatingObserver <T > {
0 commit comments