Skip to content

Instantly share code, notes, and snippets.

@eirikb eirikb/DI.kt
Created Sep 25, 2019

What would you like to do?
package gutsu
import no.eirikb.gutsu.Gutsu
interface PumpService {
fun startPump()
class DataDesk {
fun sendMessage(text: String) {
println("${hashCode()}: Sending message: $text")
class PumpView(private val pumpService: PumpService) {
init {
fun updateLabel(text: String) {
println("Update label: $text")
private fun clickPumpStart() {
class ThrusterPanel(pumpView: PumpView)
class MainPanel(thrustPanel: ThrusterPanel)
class PumpServiceImpl(private val dataDesk: DataDesk) : PumpService {
override fun startPump() {
class PumpController(dataDesk: DataDesk, view: PumpView) {
init {
view.updateLabel("Hello from controller")
println("Data desk id in controller: ${dataDesk.hashCode()}")
class App(mainPanel: MainPanel, dataDesk: DataDesk, controller: PumpController)
fun main() {
val gutsu = Gutsu()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.