ANDROID_LIVE Telegram 296
​​Самый короткий код с Dagger 2
#разработка #опрос #статьи

Когда впервые видишь Dagger, то ловишь себя на мысли, что не понимаешь, как это все работает. Видишь «волшебную» аннотацию Inject, которая без создания объекта отдает тебе его.

Конечно, при большем изучении этой библиотеки все становится яснее. И сейчас очень много статей, примеров и докладов, которые расскажут, наверное, о всех аспектах и фичах.

Но есть один пример, который призван показать «здесь и сейчас» как работает Dagger. Он не призван показать все, а только самую суть. Некий «hello world!»

 main(args: Array<String>) {
println(MainClass().info.text)
}

class MainClass {
@Inject lateinit var info : Info
init {
DaggerMagicBox.create().poke(this)
}
}

class Info @Inject constructor() {
val text = "Hello Dagger 2"
}

@Component interface MagicBox {
fun poke(mainClass: MainClass)
}


Подробнее о примере, а также ссылку на GitHub, можно найти тут.

Как вам пример?



tgoop.com/android_live/296
Create:
Last Update:

​​Самый короткий код с Dagger 2
#разработка #опрос #статьи

Когда впервые видишь Dagger, то ловишь себя на мысли, что не понимаешь, как это все работает. Видишь «волшебную» аннотацию Inject, которая без создания объекта отдает тебе его.

Конечно, при большем изучении этой библиотеки все становится яснее. И сейчас очень много статей, примеров и докладов, которые расскажут, наверное, о всех аспектах и фичах.

Но есть один пример, который призван показать «здесь и сейчас» как работает Dagger. Он не призван показать все, а только самую суть. Некий «hello world!»

 main(args: Array<String>) {
println(MainClass().info.text)
}

class MainClass {
@Inject lateinit var info : Info
init {
DaggerMagicBox.create().poke(this)
}
}

class Info @Inject constructor() {
val text = "Hello Dagger 2"
}

@Component interface MagicBox {
fun poke(mainClass: MainClass)
}


Подробнее о примере, а также ссылку на GitHub, можно найти тут.

Как вам пример?

BY Android Live 🤖




Share with your friend now:
tgoop.com/android_live/296

View MORE
Open in Telegram


Telegram News

Date: |

SUCK Channel Telegram Matt Hussey, editorial director at NEAR Protocol also responded to this news with “#meIRL”. Just as you search “Bear Market Screaming” in Telegram, you will see a Pepe frog yelling as the group’s featured image. You can invite up to 200 people from your contacts to join your channel as the next step. Select the users you want to add and click “Invite.” You can skip this step altogether. Just as the Bitcoin turmoil continues, crypto traders have taken to Telegram to voice their feelings. Crypto investors can reduce their anxiety about losses by joining the “Bear Market Screaming Therapy Group” on Telegram. The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.”
from us


Telegram Android Live 🤖
FROM American