Skip to content

Instantly share code, notes, and snippets.

@SorenV
SorenV / gist:e532d78156b663406732462ea99c1399
Created September 21, 2019 18:14
State shared between instances.
<script lang='js'>
import {createElement, ref} from '@vue/composition-api';
export default {
name: 'App',
setup() {
const tabs = ['Home', 'Posts', 'Archive'];
const currentTab = ref('Home');
package components.common
import external_js.WithRouter
import external_js.withRouter
import index.api.createUser
import index.api.dataBase
import index.model.User
import kotlinx.html.InputType
import kotlinx.html.js.onChangeFunction
import kotlinx.html.js.onClickFunction
@SorenV
SorenV / build.gradle.kts
Created July 29, 2019 22:12
build.gradke.kts
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfigWriter
val kotlinVersion = "1.3.41"
val kotlinxHtmlVersion = "0.6.12"
val kotlinExtensionsVersion = "1.0.1-pre.80-kotlin-1.3.41"
val reactVersion = "16.8.6-pre.80-kotlin-$kotlinVersion"
val reactDomVersion = "16.8.6-pre.80-kotlin-$kotlinVersion"
val reactReduxVersion = "5.0.7-pre.80-kotlin-$kotlinVersion"
val reduxVersion = "4.0.0-pre.80-kotlin-$kotlinVersion"
package index.store
import data_class.Property
import redux.RAction
data class AddProperty(val property: Property) : RAction
data class RemoveProperty(val property: Property) : RAction
package index.store
import redux.Reducer
import redux.combineReducers
import kotlin.reflect.KProperty1
/**
* Helper function that combines reducers using [combineReducers] where the keys in the map are
* properties of the state object instead of strings with the name of the state's properties
package index.store.reducers
import data_class.Property
import index.store.AddProperty
import index.store.RemoveProperty
import redux.RAction
fun properties(state: Array<Property> = emptyArray(), action: RAction): Array<Property> =
when (action) {
is AddProperty -> {
package index.store
import data_class.Property
import index.store.reducers.properties
import redux.RAction
import redux.compose
import redux.createStore
import redux.rEnhancer
class App : RComponent<AppDispatch, AppState>() {
override fun RBuilder.render() {
val property = Property(
1, "Test", "Test2", arrayListOf()
)
props.addProperty(property)
div("App-header") {
h2 {
val kotlinVersion = "1.3.41"
val kotlinxHtmlVersion = "0.6.12"
val kotlinExtensionsVersion = "1.0.1-pre.80-kotlin-1.3.41"
val reactVersion = "16.8.6-pre.80-kotlin-$kotlinVersion"
val reactDomVersion = "16.8.6-pre.80-kotlin-$kotlinVersion"
plugins {
val kotlinVersion = "1.3.41"
kotlin("js") version kotlinVersion
id("kotlin-dce-js") version kotlinVersion
rootProject.name = "kotlin_dce_duplicate_target"
pluginManagement {
repositories {
jcenter()
mavenCentral()
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {