This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val methodTime = measureTimeMillis { | |
val apiResult = runBlocking(Dispatchers.Default) { | |
val asyncResult1 = async { callApi() } | |
val asyncResult2 = async { callApi() } | |
val asyncResult3 = async { callApi() } | |
listOf(asyncResult1, asyncResult2, asyncResult3).awaitAll() | |
} | |
println(apiResult) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val methodTime = measureTimeMillis { | |
val apiResult = runBlocking(Dispatchers.Default) { | |
val asyncResult = async { callApi() } | |
asyncResult.await() | |
} | |
println(apiResult) | |
} | |
println("Time: ${methodTime}ms") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main(args: Array<String>) { | |
val apiResult = runBlocking(Dispatchers.Default) { | |
val asyncResult = async { callApi() } | |
asyncResult.await() | |
} | |
println(apiResult) | |
} | |
fun callApi(): String { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val client = OkHttpClient() | |
val okRequest = Request.Builder() | |
.url("https://httpbin.org/get") | |
.build() | |
val responseResource: Response = client.newCall(okRequest).execute() | |
return responseResource.use { | |
responseResource.body?.string()!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import { FlatList, Text } from "react-native"; | |
import { Card } from "react-native-elements"; | |
const data = [ | |
{ | |
imageUrl: "http://via.placeholder.com/160x160", | |
title: "something" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import { FlatList, Text } from "react-native"; | |
import { Card } from "react-native-elements"; | |
const data = [ | |
{ | |
imageUrl: "http://via.placeholder.com/160x160", | |
title: "something" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import { Text } from "react-native"; | |
import { Card } from "react-native-elements"; | |
export default class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
data: data | |
}; |
NewerOlder