Yes, I have some helpers. Futures are especially useful because they can
wrap failure: you don't need to catch every exception.
You can use implicits to transform a block in a Runnable, to execute it
with runOnUithread:
implicit def toRunnable[A](f: => A):Runnable =
new Runnable() { def run() = f }
future {
(Http / "geoffroycouprie.com").slurp[Char]
} onSuccess { value =>
runOnUiThread {
Toast.makeText(this, value, Toast.LENGTH_LONG).show()
}
}
On Mon, Dec 2, 2013 at 6:20 PM, Charles Monge <[email protected]> wrote:
> Hi Geoffroy,
>
> I will write an article about Future + Macroid lib which has a nice API
> for Android
>
> However Rx is very cool for long process which emit several results.
> Unfortunately, in my example I didn t show this aspect because I was
> affraid to hide Rx under a mass of code not related to Rx.
>
> May be it would be interesting to compare Rx and Future in the next
> article?
>
> Can you show me some code you are using to come back to the UI when the
> Future is finished? Did you wrote some helpers?
>
> Regards
>
>
> On Mon, Dec 2, 2013 at 11:39 AM, Geoffroy Couprie
> <[email protected]>wrote:
>
>> This is nice, I will try Rx. Usually, I wrap everything in futures,
>> because the block syntax is easy to follow, and I can return early on every
>> user input, making the UI snappy :)
>>
>>
>> On Sun, Dec 1, 2013 at 8:11 PM, Charles Monge <[email protected]>wrote:
>>
>>> If you liked the first post.... there is a new one :-) about Rx on
>>> Android in Scala...
>>>
>>> Don't hesitate to share !
>>>
>>> Regards
>>>
>>>
>>> On Friday, November 29, 2013 3:32:15 PM UTC+1, Ayoub Benali wrote:
>>>>
>>>> Great ! :)
>>>>
>>>> Le jeudi 28 novembre 2013 21:22:47 UTC+1, Charles Monge a écrit :
>>>>>
>>>>> Hi,
>>>>>
>>>>> I just started a new blog about developping on Android in Scala.
>>>>>
>>>>> Here is the address:
>>>>> http://pommedeterresautee.blogspot.fr
>>>>>
>>>>> First article about JSon serialization (Spray.IO).
>>>>>
>>>>> I am a bit new to Scala dev on Android, so there are may be points to
>>>>> fix.
>>>>>
>>>>> Don't hesitate to reach me here or comments on the blog if you see
>>>>> something that can be improved!
>>>>>
>>>>> Regards
>>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "scala-on-android" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> http://geoffroycouprie.com/em
>> http://pilotssh.com
>> https://leanpub.com/ScalaOnAndroid/
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "scala-on-android" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/scala-on-android/xFNtK7ryxZ0/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "scala-on-android" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
http://geoffroycouprie.com/em
http://pilotssh.com
https://leanpub.com/ScalaOnAndroid/
--
You received this message because you are subscribed to the Google Groups
"scala-on-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.