renlin

State managing library handles state dependencies, facilitating component creation and rendering. Offers customizable state management and efficient component interaction for dynamic web applications.

JVMJS
GitHub stars0
Open issues0
LicenseMIT License
Creation dateabout 1 year ago

Last activity7 months ago
Latest release1.3.4 (7 months ago)

hakate

About

  • A state managing library for kotlin
  • It can manage state with dependency

repository

Using

Requirement

  • kotlin
    • jvm
    • js

Getting Started

1. add to dependency

pom.xml

<dependency>
  <groupId>net.kigawa</groupId>
  <artifactId>renlin</artifactId>
  <version>{version}</version>
</dependency>

build.gradle.kts

implementation("net.kigawa:renlin:{version}")

2. write the code

write a root component

class SampleComponent(
    val name: String,
    val sub: Sub,
) {
    val root = div.component {
        t("test root")
        
        // call subcomponent
        sub.display {
        }

        fragment {
            div {
                fragment {
                    p {
                        t("text")
                    }
                }
            }
        }
        sub.controller {
        }
    }
}

write a subcomponent

class Sub(
    dispatcher: StateDispatcher,
) {
  val state: MutableState<String> = dispatcher.newState("state")

  val display = div.component {
    t("display")
    div {
      val value = state.useValue()
      t("display1")
      div {
        t("display1-1")
        p {
          t("display1-1-1 $value")
        }
      }
    }
  }
  val controller = div.component {
    t("controller")
  }
  // fragment component
  val test = fragment<FlowContent>().component { }
  val test1 = fragment<PhrasingContent>().component { }
  val test2 = fragment<FlowPhrasingIntersection>().component { }
}

set state

state.set("new value")

init endpoint

val root = document.getElementById("root") ?: throw Exception("Root not found")
val sub = Sub()
val sample = SampleComponent("sample", sub)
val dispatcher = HakateInitializer().newStateDispatcher()
Entrypoint(root).render(sample.root, dispatcher)

Author

Making

Version

Example: 9.1.2

  • 9: major, destructive
  • 1: miner, new function
  • 2: miner, bug fix
JVMJS
GitHub stars0
Open issues0
LicenseMIT License
Creation dateabout 1 year ago

Last activity7 months ago
Latest release1.3.4 (7 months ago)

hakate

About

  • A state managing library for kotlin
  • It can manage state with dependency

repository

Using

Requirement

  • kotlin
    • jvm
    • js

Getting Started

1. add to dependency

pom.xml

<dependency>
  <groupId>net.kigawa</groupId>
  <artifactId>renlin</artifactId>
  <version>{version}</version>
</dependency>

build.gradle.kts

implementation("net.kigawa:renlin:{version}")

2. write the code

write a root component

class SampleComponent(
    val name: String,
    val sub: Sub,
) {
    val root = div.component {
        t("test root")
        
        // call subcomponent
        sub.display {
        }

        fragment {
            div {
                fragment {
                    p {
                        t("text")
                    }
                }
            }
        }
        sub.controller {
        }
    }
}

write a subcomponent

class Sub(
    dispatcher: StateDispatcher,
) {
  val state: MutableState<String> = dispatcher.newState("state")

  val display = div.component {
    t("display")
    div {
      val value = state.useValue()
      t("display1")
      div {
        t("display1-1")
        p {
          t("display1-1-1 $value")
        }
      }
    }
  }
  val controller = div.component {
    t("controller")
  }
  // fragment component
  val test = fragment<FlowContent>().component { }
  val test1 = fragment<PhrasingContent>().component { }
  val test2 = fragment<FlowPhrasingIntersection>().component { }
}

set state

state.set("new value")

init endpoint

val root = document.getElementById("root") ?: throw Exception("Root not found")
val sub = Sub()
val sample = SampleComponent("sample", sub)
val dispatcher = HakateInitializer().newStateDispatcher()
Entrypoint(root).render(sample.root, dispatcher)

Author

Making

Version

Example: 9.1.2

  • 9: major, destructive
  • 1: miner, new function
  • 2: miner, bug fix