【发布时间】:2020-05-26 13:33:02
【问题描述】:
在学习 kodein 时,我经常看到 bind() with 和 bind() from。
谁能告诉我有什么区别以及我们为什么要使用它。
例如:
bind<Dice>() with provider { RandomDice(0, 5) }
bind<DataSource>() with singleton { SqliteDS.open("path/to/file") }
bind() from singleton { RandomDice(6) }
bind("DnD20") from provider { RandomDice(20) }
bind() from instance(SqliteDataSource.open("path/to/file"))
【问题讨论】: