aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/hmr
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/hmr')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/hmr/ApplicationBase.kt23
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/hmr/HMR.kt29
2 files changed, 52 insertions, 0 deletions
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<String, Any>)
+
+ /**
+ * Ending point for an application.
+ * @return final state for Hot Module Replacement (HMR).
+ */
+ abstract fun dispose(): Map<String, Any>
+}
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<String>, callback: (updated: Array<String>) -> Unit)
+
+ fun dispose(callback: (data: dynamic) -> Unit)
+}