1

I Initialize Publish Subject Rx Java in my activity like this

    private var publisher = PublishSubject.create<Int>()

And I try to create simple publish onNext like this in a button :

binding.btnFab.setOnClickListener {
        publisher.onNext(99)
    }

I try to listen the changes in function

CompositeDisposable().add(publisher.ofType(Int::class.java).subscribe(
        {
            "ON NEXT ${it}"
        },
        {
            "ON ERROR"
        },
        {
            "ON COMPLETE"
        }
    ))

But there is no one data that come out from my subscribe? do i make a mistake

  • 2
    The `ofType` filter is not needed. But what are those string literals in your observer supposed to achieve? As such they are quite much no-op. Forgot some kind of a print call? – laalto Feb 08 '22 at 11:42
  • Check if CompositeDisposable().isDisposed returns true, meaning anything you add to it will immediately get disposed, hence no notification will reach the observer. – akarnokd Feb 08 '22 at 16:06

0 Answers0