v0.15.4 #427
bitspittle
announced in
Announcements
v0.15.4
#427
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This release introduces Kobweb Workers, a wrapper around the standard web workers technology.
Note
Web workers are a way to create an isolated script that your website can run and communicate with. Web workers run on their own thread, so it's a useful place to put computationally expensive background logic (i.e. stuff that calculates things or manages complicated state and doesn't need to interact with the UI), to avoid affecting the responsiveness and performance of your main site.
Planning to upgrade? Review instructions in the README.
Getting web workers working in vanilla Kotlin/JS can be a bit of a pain (example project here), but if you are writing a Kobweb site, it couldn't be much easier.
You just create a module that applies the Kobweb Worker Gradle plugin and then implement a single interface which provides your worker logic, and Kobweb takes care of the rest. As a bonus, you can also specify rich types for your input and output messages, which we recommend using Kotlinx Serialization to help with:
and after writing that, a
CalculatePiWorker
class will be automatically generated, easy to use in your Kobweb site:Please check out the official documentation for more details.
Frontend
compose-html-ext
IntersectionObserver.
See notes section for more information.accent-color
Modifierappearance
Modifiercaption-side
Modifierclear
Modifiercolumn-rule
Modifierfont
ModifierModifier.font { style(...); size(...) }
borderRadius
ModifierModifier.borderRadius { topLeft(5.px) }
border
ModifiercssRule
API to start with a space for Descendant selectorscssRule(" h1")
, after:cssRule("h1")
cssRule(">h1")
, but in my opinion, the code reads fine without it.Backend
ApiContext
(the context value passed into@Api
methods) improvementsGradle
Notes
compose-html-ext
non-Compose bits refactored intobrowser-ext
We deprecated quite a bit of code as part of a code migration in this release. You may see a warning with this latest version of Kobweb, something that looks like:
Unfortunately, the sort of migration we're doing here is not one that we could easily provide instructions to the IDE so it could automatically replace old code with new. You'd end up with code like:
which replaces your easy to understand deprecation warning with an opaque "ambiguity" warning.
If you run into this, the best recommendation I can give you is to manually change the import statement, changing the "compose" part to "browser". For example,
com.varabyte.kobweb.
tocompose.example.stuffcom.varabyte.kobweb.browser.example.stuff
.Rationale for this migration
When we first started working on Kobweb, we needed a place to put utility methods and classes that didn't exist in Compose HTML but wish they did. So we created an artifact that even users who did not use Kobweb could pull into their Compose HTML projects and benefit from.
But we recently realized we could have gone further -- some of these utilities don't depend on Compose! But apply to Kotlin/JS browser projects more generally.
Especially with the introduction of workers (which are modules that don't depend on Compose), we decided to do the migration now.
topAndBottom
totopBottom
, etc.As we get closer to 1.0, we're reviewing some of our old code and trying to come up with consistent rules. We made the decision that "and" should not be included when it's obvious from context.
So we decided that some of our original naming was a mistake. This can cause compile errors in projects which reference parameter names like
topAndBottom
orleftAndRight
directly. If that happens, please rename them.IntersectionObserver API changes
As part of the
browser-ext
migration discussed above, a minor scar was that theIntersectionObserver
class obviously belonged in the non-Compose part, but the API provided bycompose-html-ext
did use a nice, richCSSMargin
type that ultimately requires Compose HTML.Therefore, we moved the class into
browser-ext
but added a new extension constructor incompose-html-ext
. If you happened to be using this constructor, you'll get a compile error. You can fix this by importing the extension constructor (which is implemented as aninvoke
operator on theOption
class).You could of course consider doing the following, which sidesteps importing "invoke":
Thanks!
We had some new contributors in this release.
Thanks so much for taking your time to help Kobweb be a better project!!
And perhaps more than usual, thanks to @DennisTsar for helping me navigate myself out of countless dead ends for poor approaches I took with the Worker feature.
Full Changelog: v0.15.3...v0.15.4
This discussion was created from the release v0.15.4.
Beta Was this translation helpful? Give feedback.
All reactions