GCX-HCI / ThirtyInch

a MVP library for Android favoring a stateful Presenter
Apache License 2.0
1.03k stars 101 forks source link

Fix wrong usage of hasLifecycleMethodBeenCalled in TiCoroutineScope #192

Closed Syex closed 5 years ago

Syex commented 5 years ago

I tried to use the new coroutines module and launch a job in onAttachView() via TiCoroutineScope.launchUntilViewDetaches {}, but got an exception that the view is not attached.

Due to the check if (!hasLifecycleMethodBeenCalled) return@addLifecycleObserver, to not call things twice, the required Job was indeed not initialized, yet.

Now we avoid the second lifecycle call instead. Practically this means we initialize everything before onAttachView() is called and not after.