Closed Syex closed 5 years ago
Kotlim 1.3.20 is already released
On Fri, Jan 25, 2019, 2:52 PM Tom Seifert <notifications@github.com wrote:
This PR adds a new module for Kotlin's coroutines which contains a custom CoroutineScope to be used when starting coroutines in a TiPresenter. The so started coroutines are then bound to the lifecycle of the presenter.
Mostly it will behave similar to the RxTiPresenterDisposableHandler introduced in #161 https://github.com/grandcentrix/ThirtyInch/pull/161, but instead of having to add disposeWhenDestroyed or disposeWhenViewDetached the TiCoroutineScope will cancel jobs automatically when the presenter reaches the specific lifecycle state.
If there's a better workaround to saving the last presenterState in a variable please let me know, maybe I just misunderstood the calls 🤷♂️
You can view, comment on, or merge this pull request online at:
https://github.com/grandcentrix/ThirtyInch/pull/182 Commit Summary
- Add new Kotlin Coroutines module
- Add TiCoroutineScope and a test
- Add new module to README
File Changes
- M README.md https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-0 (30)
- M build.gradle https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-1 (2)
- M settings.gradle https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-2 (1)
- A thirtyinch-kotlin-coroutines/.gitignore https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-3 (1)
- A thirtyinch-kotlin-coroutines/build.gradle https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-4 (39)
- A thirtyinch-kotlin-coroutines/proguard-rules.pro https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-5 (21)
- A thirtyinch-kotlin-coroutines/src/main/AndroidManifest.xml https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-6 (1)
- A thirtyinch-kotlin-coroutines/src/main/java/net/grandcentrix/thirtyinch/kotlin/coroutines/TiCoroutineScope.kt https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-7 (46)
- A thirtyinch-kotlin-coroutines/src/test/java/net/grandcentrix/thirtyinch/kotlin/coroutines/TiCoroutineScopeTest.kt https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-8 (54)
Patch Links:
- https://github.com/grandcentrix/ThirtyInch/pull/182.patch
- https://github.com/grandcentrix/ThirtyInch/pull/182.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grandcentrix/ThirtyInch/pull/182, or mute the thread https://github.com/notifications/unsubscribe-auth/AJwYe3UpthcC4vFtOxJqiqhDgpuNgwjhks5vGwwPgaJpZM4aS6oM .
The Readme is wrong with the view detaching.. We have to add the boolean "true" als third param.. Beside if that. Does this really require to create each time a new view got attached?
On Fri, Jan 25, 2019, 3:20 PM Stefan M. <stefanmay91@gmail.com wrote:
Kotlim 1.3.20 is already released
On Fri, Jan 25, 2019, 2:52 PM Tom Seifert <notifications@github.com wrote:
This PR adds a new module for Kotlin's coroutines which contains a custom CoroutineScope to be used when starting coroutines in a TiPresenter. The so started coroutines are then bound to the lifecycle of the presenter.
Mostly it will behave similar to the RxTiPresenterDisposableHandler introduced in #161 https://github.com/grandcentrix/ThirtyInch/pull/161, but instead of having to add disposeWhenDestroyed or disposeWhenViewDetached the TiCoroutineScope will cancel jobs automatically when the presenter reaches the specific lifecycle state.
If there's a better workaround to saving the last presenterState in a variable please let me know, maybe I just misunderstood the calls 🤷♂️
You can view, comment on, or merge this pull request online at:
https://github.com/grandcentrix/ThirtyInch/pull/182 Commit Summary
- Add new Kotlin Coroutines module
- Add TiCoroutineScope and a test
- Add new module to README
File Changes
- M README.md https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-0 (30)
- M build.gradle https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-1 (2)
- M settings.gradle https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-2 (1)
- A thirtyinch-kotlin-coroutines/.gitignore https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-3 (1)
- A thirtyinch-kotlin-coroutines/build.gradle https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-4 (39)
- A thirtyinch-kotlin-coroutines/proguard-rules.pro https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-5 (21)
- A thirtyinch-kotlin-coroutines/src/main/AndroidManifest.xml https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-6 (1)
- A thirtyinch-kotlin-coroutines/src/main/java/net/grandcentrix/thirtyinch/kotlin/coroutines/TiCoroutineScope.kt https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-7 (46)
- A thirtyinch-kotlin-coroutines/src/test/java/net/grandcentrix/thirtyinch/kotlin/coroutines/TiCoroutineScopeTest.kt https://github.com/grandcentrix/ThirtyInch/pull/182/files#diff-8 (54)
Patch Links:
- https://github.com/grandcentrix/ThirtyInch/pull/182.patch
- https://github.com/grandcentrix/ThirtyInch/pull/182.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/grandcentrix/ThirtyInch/pull/182, or mute the thread https://github.com/notifications/unsubscribe-auth/AJwYe3UpthcC4vFtOxJqiqhDgpuNgwjhks5vGwwPgaJpZM4aS6oM .
Beside if that. Does this really require to create each time a new view got attached?
I was prepared for that question! Yes we have to. The CoroutineScope
requires its property coroutineContext
to be final. We're initializing it with a Job()
, which we cancel later. Once it is canceled we can't restart it and we can't reassign the coroutineContext
. Do you see any other option?
Changed the implementation. The flag, whether the scope should cancel all jobs when the view detaches, is no longer required to be constructor parameter.
Instead, there's now a method launchUntilViewDetaches
on the scope which should be used for this case, rather than the default launch
method.
This PR adds a new module for Kotlin's coroutines which contains a custom
CoroutineScope
to be used when starting coroutines in aTiPresenter
. The so started coroutines are then bound to the lifecycle of the presenter.Mostly it will behave similar to the
RxTiPresenterDisposableHandler
introduced in #161, but instead of having to adddisposeWhenDestroyed
ordisposeWhenViewDetached
theTiCoroutineScope
will cancel jobs automatically when the presenter reaches the specific lifecycle state.If there's a better workaround to saving the last
presenterState
in a variable please let me know, maybe I just misunderstood the calls 🤷♂️