Skip to content

Instantly share code, notes, and snippets.

@ubarua123
Last active January 13, 2020 11:50
Show Gist options
  • Save ubarua123/985379f22ac11bcac09594a6554adcbd to your computer and use it in GitHub Desktop.
Save ubarua123/985379f22ac11bcac09594a6554adcbd to your computer and use it in GitHub Desktop.
public class SampleWorker extends RxWorker {
// Our custom parameter
private final Retrofit retrofit;
@Inject
public SampleWorker(
@NonNull Context context,
@NonNull WorkerParameters parameters,
Retrofit retrofit) {
super(context, parameters);
this.retrofit = retrofit;
}
public Single<Result> createWork() {
// Create a single observer which will hit a url and nothing else.
return Observable.range(0, 100)
.flatMap { download("https://www.google.com") }
.toList()
.map { Result.success() };
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment