https://kotlinlang.org logo
d

dave08

09/26/2017, 3:33 PM
This is my kodein module for now 😞 :
Copy code
bind<ConfigRetriever>() with singleton { ConfigRetriever.create(instance()) }

	bind<SQLClient>() with singleton { 
		instance<ConfigRetriever>().rxGetConfig()
				.map { config ->
					PostgreSQLClient.createShared(instance(), json {
						obj (
								"host" to config.getString("HOST"),
								"port" to config.getInteger("PORT"),
								"database" to config.getString("DB_NAME"),
								"username" to config.getString("DB_USER"),
								"password" to config.getString("DB_PASS")
						)
					})
				}.onErrorReturn { null }.toBlocking().value()
	}