Creating a RX Observable without calling onComplete is it Valid?

I am doing a polling operation which I have to wait for updates and I created Rx Observable for that; however, I never call onComplete. but in onDestroy I unsubscribe. please take a look on the below code.

    @Reusable
class TestPolling @Inject constructor() {
    var itemObservable: Observable<List<Items>>
        private set
    private lateinit var itemObservableEmitter: WeakReference<ObservableEmitter<List<Items>>>

    init {
        itemObservable = Observable.create { e -> itemObservableEmitter = WeakReference(e) }
    }

    fun submitData(items: List<Items>) {
        itemObservableEmitter.get()?.onNext(items)
    }
}

so is Valid to do something like that. I am not expert in Rx sorry if it is trivial question.

I am not an RxJava expert, and so I have no idea whether your approach is considered to be a valid RxJava pattern or not. Sorry!

1 Like