Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Basic implementation for TI kotlin #150

Merged
merged 9 commits into from
Jul 10, 2018
Merged

Basic implementation for TI kotlin #150

merged 9 commits into from
Jul 10, 2018

Conversation

StefMa
Copy link
Contributor

@StefMa StefMa commented Jul 6, 2018

This will introduce a "basic" implementation for Ti-Kotlin.

Currently it is just the module and the extension function
TiPresenter.deliverToView(block: View.() -> Unit).
See also this PR: #142

I'm not quite happy with the function name. But because Kotlin uses the implementation function over the extension function it isn't possible to name them equally.
If you have a better name feel free to post it here...

* ```
*/
@SuppressLint("RestrictedApi")
fun <V : TiView> TiPresenter<V>.sendToViewKotlin(block: V.() -> Unit) = sendToView { block.invoke(it) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about at least name it sendToViewKt as all Kotlin stuff is suffixed with Kt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some alternatives: withView, withAttachedView, waitForView

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the recommendation.
I think we should go with @Syex idea here because... well, it make sense 🙃

Using a complete different name for an "extension" is just confusing IMO.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to go with @passsy 's suggestion. We should not include some language specific abbreviations in our public API.
My prefered candidate would be withView. Reason: It makes sense.

@passsy
Copy link
Contributor

passsy commented Jul 9, 2018

deliverToView { }?

  • send implies a synchronous call (which is only true when the view is attached)
  • post implies an asynchronous call (although it may be synchronous)
  • deliver doesn't tell how or when it is delivered which is a good fit for this function.

@StefMa
Copy link
Contributor Author

StefMa commented Jul 9, 2018

🔴 Ready for another round 👍
Thanks @passsy Great suggestion

README.md Outdated
@@ -250,6 +253,30 @@ public class HelloWorldActivity extends TiActivity<HelloWorldPresenter, HelloWor

`LoggingInterceptor` is available as module and logs all calls to the view.

### Kotlin

Using Kotlin these days is a no brainer.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a part that the user has to include net.grandcentrix.thirtyinch:thirtyinch-kotlin

README.md Outdated
Using Kotlin these days is a no brainer.
`ThirtyInch` provides some extension methods to improve itself even further!

Take a look at the `sendToViewKt` example:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change sendToViewKt here to deliverToView aswell

* ```
*/
@SuppressLint("RestrictedApi")
fun <V : TiView> TiPresenter<V>.deliverToView(block: V.() -> Unit) = sendToView { block.invoke(it) }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to write block(it) instead of block.invoke(it)

@jreehuis
Copy link

jreehuis commented Jul 9, 2018

Nice addition @StefMa ! 🐶

@jreehuis jreehuis dismissed their stale review July 10, 2018 11:16

fixed

@passsy passsy merged commit bcd6203 into GCX-HCI:master Jul 10, 2018
@StefMa StefMa deleted the tikotlin branch August 1, 2018 06:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

4 participants