From 70d2f14d4a34f841a3161482eec5d355cbd755f6 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 4 Feb 2018 21:49:23 +0100 Subject: Refactoring packages layout --- .../pl/treksoft/kvision/hmr/ApplicationBase.kt | 23 +++++++++++++++++ src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt | 29 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt (limited to 'src/main/kotlin/pl/treksoft/kvision/hmr') diff --git a/src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt b/src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt new file mode 100644 index 00000000..ceea0fbc --- /dev/null +++ b/src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt @@ -0,0 +1,23 @@ +/** + * @author Robert Jaros + */ +package pl.treksoft.kvision.hmr + +/** + * Base class for applications. + * + * Base class for applications supporting Hot Module Replacement (HMR). + */ +abstract class ApplicationBase { + /** + * Starting point for an application. + * @param state Initial state between Hot Module Replacement (HMR). + */ + abstract fun start(state: Map) + + /** + * Ending point for an application. + * @return final state for Hot Module Replacement (HMR). + */ + abstract fun dispose(): Map +} diff --git a/src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt b/src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt new file mode 100644 index 00000000..59b6fe00 --- /dev/null +++ b/src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt @@ -0,0 +1,29 @@ +/** + * @author Robert Jaros + */ +package pl.treksoft.kvision.hmr + +/** + * Helper variable for Hot Module Replacement (HMR). + */ +external val module: Module + +/** + * Helper interface for Hot Module Replacement (HMR). + */ +external interface Module { + val hot: Hot? +} + +/** + * Helper interface for Hot Module Replacement (HMR). + */ +external interface Hot { + val data: dynamic + + fun accept() + fun accept(dependency: String, callback: () -> Unit) + fun accept(dependencies: Array, callback: (updated: Array) -> Unit) + + fun dispose(callback: (data: dynamic) -> Unit) +} -- cgit