Skip to content

Instantly share code, notes, and snippets.

@eirikb
Created September 25, 2019 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eirikb/442457e9e81a9276b0f63850be082c86 to your computer and use it in GitHub Desktop.
Save eirikb/442457e9e81a9276b0f63850be082c86 to your computer and use it in GitHub Desktop.
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 {
clickPumpStart()
}
fun updateLabel(text: String) {
println("Update label: $text")
}
private fun clickPumpStart() {
pumpService.startPump()
}
}
class ThrusterPanel(pumpView: PumpView)
class MainPanel(thrustPanel: ThrusterPanel)
class PumpServiceImpl(private val dataDesk: DataDesk) : PumpService {
override fun startPump() {
dataDesk.sendMessage("PUMP_START")
}
}
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()
gutsu.bind(PumpServiceImpl::class.java, PumpService::class.java)
gutsu.getInstance(App::class.java)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment