All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.uber.autodispose.ObservableScoper Maven / Gradle / Ivy

There is a newer version: 1.4.1
Show newest version
/*
 * Copyright (c) 2017. Uber Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.uber.autodispose;

import io.reactivex.Maybe;
import io.reactivex.Observable;
import io.reactivex.functions.Function;

/**
 * Entry point for auto-disposing {@link Observable}s.
 * 

* The basic flow stencil might look like this: *


 *   myThingObservable
 *        .to(new ObservableScoper(...))
 *        .subscribe(...)
 * 
*

* There are several constructor overloads, with the most basic being a simple {@link * #ObservableScoper(Maybe)}. The provided {@link Maybe} is ultimately what every scope resolves to * under the hood, and AutoDispose has some built-in understanding for predefined types. The scope * is considered ended upon onSuccess emission of this {@link Maybe}. The most common use case would * probably be {@link #ObservableScoper(ScopeProvider)}. * * @param the stream type. * @deprecated Use the static factories in {@link AutoDispose}. This will be removed in 1.0. */ @Deprecated public class ObservableScoper extends BaseAutoDisposeConverter implements Function, ObservableSubscribeProxy> { public ObservableScoper(ScopeProvider provider) { super(provider); } public ObservableScoper(LifecycleScopeProvider provider) { super(provider); } public ObservableScoper(Maybe lifecycle) { super(lifecycle); } @Override public ObservableSubscribeProxy apply(final Observable observableSource) { return observableSource .map(BaseAutoDisposeConverter.identityFunctionForGenerics()) .as(AutoDispose.autoDisposable(scope())); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy