Version 0.7
breaking changes
This release contains changes that break code written with earlier versions:
Handler
s are now suspendable, so you can call suspend-methods directly inside yourHandler
. There is no need forApplicator
anymore. Therefore this class and its utility-functions have been removed. (PR#124 & PR#126)FormateStore
and interfaceFormat
have been removed. Useformat
-factory-function insidelenses
package to create a formattingLens
and create a normalSubStore
(by usingsub
). (PR#139 & PR#146)
val df: DateFormat = DateFormat("yyyy-MM-dd")
// converts a Date into String in vice versa
val dateFormat = format(
parse = { df.parseDate(it) },
format = { df.format(it) }
)
//using the dateLens
val birthday = personStore.sub(L.Person.birthday + dateFormat)
// or
val birthday = personStore.sub(L.Person.birthday).sub(dateFormat)
in commonMain
data class Message(val id: String, val status: Status, val text: String) : ValidationMessage {
override fun isError(): Boolean = status > Status.Valid // renamed from failed() -> isError()
}
object PersonValidator : Validator<Person, Message, String>() {
// return your validation messages here
override fun validate(data: Person, metadata: String): List<Message> {
...
}
}
in jsMain
val personStore = object : RootStore<Person>(Person()) {
// only update when it's valid
val addOrUpdate = handle<Person> { oldPerson, newPerson ->
if (PersonValidator.isValid(newPerson, "update")) new else oldPerson
}
}
...
// then render the validation message list in your html
PersonValidator.msgs.render { msg ->
...
}.bind()
in jvmMain
if (PersonValidator.isValid(newPerson , "add")) {
//e.g. save your new Person to Database
...
} else {
// get the messages, only available after isValid() was called
val msgs = PersonValidator.msgs
...
}
new features
- added tracking-service to access process state of
Handler
s (e.g. to show process indicator). (PR#147) - added history-service to keep track of historical values in
Store
s and provideback()
function. (PR#152) - added
Repository
to offer CRUD-functionality for entities and dealing with queries. Implementations are available for REST and LocalStorage (see example). (PR#141, PR#144, PR#155 & PR#153) - added
storeOf()
function to create a minimalRootStore
(withoutHandler
s) (PR#144) - added convenience-function
render
onSeq
, so you can directly writeeach(...).render { ... }
(and leave outmap
) (PR#142) - added convenience-function
render
onFlow
, so you can directly writeflow.render { ... }
(and leave outmap
) (PR#154) - added functions to deal with errors in
Handler
s (PR#137) - snapshots are now provided on oss.jfrog.org (PR#128)
- added
append
function to remote (PR#127) - changed
IdProvider
to generic type (PR#123) - use
Inspector
(created byinspect()
-function) to navigate through your model in validation and test and have data and corresponding ids available at any point (PR#118)