Skip to content

Releases: jwstegemann/fritz2

Version 0.7

13 Aug 21:39
Compare
Choose a tag to compare

breaking changes

This release contains changes that break code written with earlier versions:

  • Handlers are now suspendable, so you can call suspend-methods directly inside your Handler. There is no need for Applicator anymore. Therefore this class and its utility-functions have been removed. (PR#124 & PR#126)
  • FormateStore and interface Format have been removed. Use format-factory-function inside lenses package to create a formatting Lens and create a normal SubStore (by using sub). (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)
  • Validation has been extracted as a service and refactored to be more concise. (PR#149 & #157)

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 Handlers (e.g. to show process indicator). (PR#147)
  • added history-service to keep track of historical values in Stores and provide back() 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 minimal RootStore (without Handlers) (PR#144)
  • added convenience-function render on Seq, so you can directly write each(...).render { ... } (and leave out map) (PR#142)
  • added convenience-function render on Flow, so you can directly write flow.render { ... } (and leave out map) (PR#154)
  • added functions to deal with errors in Handlers (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 by inspect()-function) to navigate through your model in validation and test and have data and corresponding ids available at any point (PR#118)

fixed bugs

  • added isValid on JVM (PR#135)
  • added missing factories for <dt> and <dd> (PR#134)
  • added missing SelectedAttributeDelegate (PR#131)
  • fixed some bugs in Router and minor API changes (PR#151)

Version 0.6

13 Jul 11:40
Compare
Choose a tag to compare

breaking changes

This release contains changes that break code written with earlier versions:

  • You no longer need to inherit WithId in your model-classes (the interface has been removed from fritz2 entirely). Instead, you need to provide a function which returns the id of a certain instance. This function can be used when calling each or creating a SubStore for a certain element (PR#94):
// in commonMain
@Lenses
data class Model(val id: String, val value: String)

// in jsMain
val store = RootStore<List<Model>>(listOf(...))

render {
  ul {
    store.each(Model::id).map { modelStore ->
      render {
        li { modelStore.sub(L.Model.value).data.bind() }
      }
    }.bind()
  }
}.mount("target")
  • All of the each methods (PR#113) were unified:

    • use Flow<T>.each() to map each instance of T to your Tags. It uses Kotlin's equality function to determine whether or not two elements are the same, and therefore re-renders the whole content you mapped when an element is changed or moved.

    • with Flow<T>.each(idProvider: (T) -> String) you can also map each instance of T to your Tags, but it uses the given idProvider to determine whether or not two elements are the same. In your mapping, you can get a SubStore for an element using listStore.sub(id, idProvider), so only the parts that actually changed will be re-rendered.

    • use Store<List<T>>.each() to map a SubStore<T> to Tags. It uses the list position of the element to determine whether or not two elements are the same. This means that when inserting something into the middle of the list, the changed element AND ALL following elements will be re-rendered.

    • with Store<List<T>>.each(idProvider: (T) -> String) you can also map a SubStore<T> to Tags, but it uses the given idProvider to determine whether or not two elements are the same`, so only the parts that actually changed will be re-rendered.

    • renamed handleAndEmit to handleAndOffer (PR#109)

    • renamed ModelIdRoot to RootModelId to follow the naming of stores (PR#96)

new features

  • add static text in HTML by +"yourText" (PR#95)
  • add HTML-comments by comment("yourText") or !"yourText" (PR#108)
  • use the action function to dispatch an action at any point in your code (PR#117)

fixed bugs

  • fixed handling of value and checked attributes (PR#81)
  • fixed MapRouter to use Map<String,String> (PR#82)
  • fixed double kotlin-block in gradle build-file (PR#97)
  • ensure order of children when mixing static tags with bound values on the same level by using bind(preserveOrder = true) (PR#102)
  • classes of HTML-tags are now open so you can inherit your own tags from them (PR#104)
  • SingleMountPoint for Boolean (leaving out the attribute if false) (PR#105)

Version 0.5

11 Jun 14:27
0e77587
Compare
Choose a tag to compare

breaking changes

This release contains changes, that break code written with earlier versions:

  • We moved all artifacts and packages to match our domain: dev.fritz2. You will have to adjust your inputs and dependencies accordingly.
  • The default project-type for fritz2 now is multiplatform (to make it easy to share models and validation between client and server). Use the new fritz2-gradle-plugin to setup your project:

build.gradle.kts

plugins {
    id("dev.fritz2.fritz2-gradle") version "0.5"
}

repositories {
    jcenter()
}

kotlin {
    kotlin {
        jvm()
        js().browser()

        sourceSets {
            val commonMain by getting {
                dependencies {
                    implementation(kotlin("stdlib"))
                }
            }
            val jvmMain by getting {
                dependencies {
                }
            }
            val jsMain by getting {
                dependencies {
                }
            }
        }
    }
}

fixed bugs

  • fixed dom-update problem with checked attribute at HTMLInputElement

Version 0.4

26 May 20:35
391d73d
Compare
Choose a tag to compare

breaking changes

This release contains changes, that break code written with earlier versions:

  • since it was the source of much confusion we renamed the function to build a tree of Tags (formerly html) to render:
render {
    div("my-class") {
        // ...
    }
}
  • the overloaded operator <= to bind a Flow of actions or events to a Handler was definitely not Kotlin-like, so we replaced it by the handledBy infix-function (please note the reversed order):
button("btn btn-primary") {
    text("Add a dot")
    clicks handledBy store.addADot
}

new features

  • improved remote-api
  • support for building and using WebComponents

bug fixes

  • improved examples
  • improved documentation

build.gradle.kts

Kotlin style

dependencies {
    implementation("io.fritz2:fritz2-core-js:0.4")
}

Groovy style

dependencies {
    implementation 'io.fritz2:fritz2-core-js:0.4'
}

Version 0.3

22 Apr 19:20
Compare
Choose a tag to compare
  • several bug-fixes
  • tidyed up syntax for text, attr, const
  • better examples
  • Improved diff-algorithm for list-handling
  • better extractions on events (current value, selected item, etc.)
  • reworked structure of GitHub-projects

Version 0.2

19 Mar 20:26
61f8665
Compare
Choose a tag to compare

First automated release using github actions...

Version 0.1

28 Feb 20:53
Compare
Choose a tag to compare
Version 0.1 Pre-release
Pre-release

Our first public release, just to test the build- and publish-process.