Ramonda

persist-of-a-lossy-value

This fails the run. Where it is wrong about your code, // ramonda-check-ignore <reason> on the line says so, and the reason is printed on every run.

Reported when a @persist field holds a Map, a Set, a Date, a function or a class instance, none of which JSON carries.

The framework reports the same fault while running, as RMD033 — but only once the line actually runs. This is the same fault proved from the source instead.

@persist does one thing: it puts a field into the hydration blob, which is JSON. It creates no signal and has no other effect, so a value JSON cannot carry makes the decorator do nothing — quietly, because none of these throws on the way out. A Map becomes {} and a Date becomes a string, and the page fails later, somewhere else, on a method the value no longer has.

Persist a form of it that survives — an id, an ISO string, an array of entries — and rebuild the object where it is used, or in a @compute beside it. Where the value is only ever needed in the browser, build it in @created, which hydration skips, and do not persist it at all.

Next