aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/HMR.kt
blob: 6fb9dfed1e62c8a51a8180a74a486f6a81b15284 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 * @author Robert Jaros
 */
package pl.treksoft.kvision

/**
 * 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)
}

/**
 * External function for loading CommonJS modules.
 */
external fun require(name: String): dynamic