Giter VIP home page Giter VIP logo

Comments (2)

akarnokd avatar akarnokd commented on May 26, 2024

Those nulls are internal affairs so unless you can exclude any class with that feature, no idea.

from rxjava.

ritesh-singh avatar ritesh-singh commented on May 26, 2024

Sure, thank you. With limited understanding of how Rx2 deals with fusion internally. After give this blog a read - my assumption is, Rx fusion library is adding null in the stream in case of Asynchronous-fusion

Taking below para into consideration

In asynchronous-fusion mode, downstream has to still issue request() calls, but instead of enqueueing the value twice, the value gets generated into the shared queue and the upstream calls onNext() indicating its availability. The value of this call is irrelevant, we use null as a type-neutral value, and can trigger the usual drain() call directly.

I am wondering, if it's safe to assume not to call onNext on downstream observers when Rx fusion code calls onNext(null), getting invoked via upstream observer.

Below is the basic code snippet implementation of otel code in kotlin which deals with fusion.

// downstream  
internal class TracingObserver<T>( 
  private val wrappedObserver: Observer<in T>,
  private val context: Context,
) : BasicFuseableObserver<T, T>(
  wrappedObserver
) {
  override fun onNext(t: T & Any) { // it throws exception when it gets called via fusion
    context.makeCurrent().use { _ -> wrappedObserver.onNext(t) }
  }
......
}
// upstream 
internal class TracingSingleObserver<T>(
  private val actual: SingleObserver<T>,
  private val context: Context,
) : SingleObserver<T>, Disposable {
  private var disposable: Disposable? = null
  override fun onSubscribe(d: Disposable) {
    if (!DisposableHelper.validate(disposable, d)) {
      return
    }
    disposable = d
    actual.onSubscribe(this)
  }

  override fun onSuccess(t: T & Any) {
    context.makeCurrent().use { _ -> actual.onSuccess(t) } // upstream 
  }
....
}

I was wondering, if there are any implication, if i just handle the exception in TracingSingleObserver#onSuccess which will invoke RxFusion with onNext(null) but catches the exception thrown via TracingObserver#onNext.
Can there be any implications if wrappedObserver.onNext(null) isn't called in the RxStream.

Thanks, i need to dig in more!

from rxjava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.