aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/hmr
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-02-04 21:49:23 +0100
committerRobert Jaros <rjaros@finn.pl>2018-02-04 21:49:23 +0100
commit70d2f14d4a34f841a3161482eec5d355cbd755f6 (patch)
tree847cb461a2f261f6f2b3a6b0ebbc6918f1da0467 /src/main/kotlin/pl/treksoft/kvision/hmr
parent9665fe692681bc958e55d00cc0d0b238b7aee694 (diff)
downloadkvision-70d2f14d4a34f841a3161482eec5d355cbd755f6.tar.gz
kvision-70d2f14d4a34f841a3161482eec5d355cbd755f6.tar.bz2
kvision-70d2f14d4a34f841a3161482eec5d355cbd755f6.zip
Refactoring packages layout
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)
+}