Ndechipi musiyano pakati Scala Future onComplete uye andThen mabasa?
Zvose zviri zviviri `andThen` uye `onComplete` zvinokutendera kuti uone mugumisiro weimwe nguva yemberi kuburikidza ne callback function. Zvisinei, `andThen` inogona kuiswa mumaketani, uye kusiyana ne `onComplete`, inovimbisa kurongeka uko mabasa ekudzoka achashandiswa. Mukuwedzera, callback yakapiwa ku `andThen` inogona kuva basa risina kukwana, rinobata chete subset yemigumisiro (semuenzaniso, chete `Success` kana chete `Failure`).  Rangarira muenzaniso unotevera uchishandisa `andThen` uye `map`:  ` ` ` def demoAndThen(fut: Future[Int]): Future[Int] = { fut.andThen { chiitiko Kubudirira (((kukosha) => println (((s"andThen1: $ kukosha") } .andThen {kero Kubudirira (((kukosha) => println (((s"andThen2: $kukosha") } . {map i => println ((s"map: $i") I } } ` ` `  Apo `fut` inopedza zvinobudirira, "andthen1:...", "andThen2:..." uye "map:..." zvichadhindwa mumutsara iwoyo.  Rangarira muenzaniso wakafanana uchishandisa `onComplete` uye `map`:  ` ` ` def demoOnComplete(fut: Future[Int]): Future[Int] = { futonComplete { t: Try[Int] => println(s"onComplete1: $t") } futonComplete { t: Try[Int] => println(s"onComplete2: $t") } fut.map { i => println ((s"map: $i") I } } ` ` `  Muchiitiko ichi, apo `fut` inopedza zvinobudirira, "onComplete1:...", "onComplete2:..." uye "mepu:..." zvichadhindwa mune imwe hurongwa husina kutaurwa.  Kunyange zvazvo `andThen` yakasungwa, callback function haibatsiri pamigumisiro ye `Future`. Asi ngwarira: kana kudanazve kuchikandira mhosho dzinoparira rufu, nguva yemberi inoguma haisati ichizotongopedza.