0

Is it possible to access the first argument of the operators down the line? I'm trying to preserve the value using the zip operator but I haven't managed to do it. Thanks for the help

.concatMap(this::getDeviceStatus)
                .concatMap(this::getCertificateResponse)
                .concatMap(deviceCertificateResponse ->
                        CertificateGenerator.generateCert(deviceCertificateResponse))
                .concatMap(aBoolean -> CrlGenerator.observableCrlGenerator(aBoolean,getCertificateResponse ))  // <- I want to use the first argument again in the last concat map
Maksim Ostrovidov
  • 10,720
  • 8
  • 42
  • 57
george_mx
  • 376
  • 3
  • 20

1 Answers1

1

You could preserve your upstream argument via nesting:

Observable.just("initialValue")
    .concatMap(initialValue -> {
        someMethod(initialValue)
            .concatMap(transformedValue -> anotherMethod(initialValue, transformedValue))
    });

Also, when using Observables and flatMaps, nesting could be replaced with flatMap overload with result selector.

Maksim Ostrovidov
  • 10,720
  • 8
  • 42
  • 57