fritz2 v0.6 Release Notes

Release Date: 2020-07-13 // almost 4 years ago
  • ๐Ÿ’ฅ 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@Lensesdata class Model(val id: String, val value: String)// in jsMainval 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)