Closed lukaszkalnik closed 5 years ago
What about for convenience adding a subclass of TiPresenter
that implements the DisposableHandler
for me? I'm sure we mostly have this class in our projects already and it would be the first thing I'd do in a project, because it adds that extra interface implementation and override as noise is every presenter otherwise.
The overhead when not needing the disposableHandler
would be less important to me than having to implement and override this every time.
@Syex it's a good idea, although this interface was specifically meant as composition over inheritance, to not require a BasePresenter
class to be extended by every Presenter.
But I will provide a convenience implementation of it.
For our projects this really is a big win. But I do not like that we will include RxJava in each project which uses the Kotlin module. I guess there are projects which do not want to use RxJava but the Kotlin module.
@jreehuis then maybe we should put it in the thirtyinch-rx2 module? This is probably semantically more fitting, because indeed as you noticed it is related only to Rx usage in ThirtyInch.
@lukaszkalnik Than you get the issue that maybe someone want to use Rx but not Kotlin. But I guess that way around would be better fitting. What does the others think?
I think most Android projects are moving to Kotlin sooner or later.
@passsy (and others), do we want this added or not? If we don't want to add Kotlin support to ThirtyInch just for this small helper I think we should make a decision and close the PR. I'm fine with that.
I think the best solution would be to just publish it as a gist and link to it in the README.
Create Kotlin helper interface
DisposableHandler
to be implemented byTiPresenter
to provide syntactic sugar forDisposable
handling.Implementing this interface by your Presenter enables you to call
.disposeWhenDestroyed()
and.disposeWhenViewDetached()
as extension functions directly on yourDisposable
instances.Usage: