Actually, this is similar to what you can do in Java by using lambdas (Retrolambda for pre-Java 8, e.g. Android pre-SDK 24). Excerpt from a blog post [1] about it:
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// do something here
}
});
can be replaced with
mButton.setOnClickListener((View v) -> {
// do something here
});
which is nice for all callbacks, but especially together with ReactiveX where they are abundant.
I'd say that depends on which languages you already know. Go is a smaller language in terms of syntax. No generics, not OO in the sense that it doesn't have classes and inheritance etc. But if you're familiar with the Java ecosystem and languages like Scala, or something like Swift or Rust, Kotlin should be easy to pick up.
Personally I don't feel the need to use React if you use kotlin. But there are few cases where React makes sense. Everything that involves a stream of events that you need to process and they can fail or you need to retry, them React is your way to go (I don't feel kotlin is ready for this use case yet). For example, if you want to use the BlueTooth API it is so easy to use it with React because of the stream of events.
People are using React for Rest requests, and for APIs where you cannot touch them it can be a good idea as it provide ways to join results of requests and other stuff. But if you control the API and it is designed to be simple and with mobile in mind, there shouldn't be uses cases where a simple request give you all you need.
It also gives consistency as you treat the same way a click event than a http request. Some people like this but I don't.
I personally didn't find a good use case to use it in my app, but you might think diferently. So, I suggest you to try it a little at least an decide by yourself.
16 comments
[ 3.5 ms ] story [ 37.4 ms ] threadAs a Kotlin noob, can someone explain to me why the Kotlin on-click listener doesn't need to specify onClick() like the Java one does?
[1] http://zserge.com/blog/android-lambda.html
mButton.setOnClickListener { /* do something here */ }
(In addition to SAM conversions, both the parenthesis and input variable are optional.)
As good as it is, Kotlin can't fully mask the awful boilerplate and APIs .
I haven't tinkered with mobile development in awhile, but I remember content providers feeling like an oddly thought-out concept at the time.
People are using React for Rest requests, and for APIs where you cannot touch them it can be a good idea as it provide ways to join results of requests and other stuff. But if you control the API and it is designed to be simple and with mobile in mind, there shouldn't be uses cases where a simple request give you all you need.
It also gives consistency as you treat the same way a click event than a http request. Some people like this but I don't.
I personally didn't find a good use case to use it in my app, but you might think diferently. So, I suggest you to try it a little at least an decide by yourself.
This can get you started: http://reactivex.io/intro.html