Open Olovyannikov opened 1 month ago
form is a model, which can't be persistable by default. We have two possible ways to resolve this problem:
$persisted
store (or with another name), which changes form values while writing and serializing into plain object while readingpersist({
store: form.$persisted,
key: 'form',
});
persistForm
function which has similar mechanism but in separated function.const persistedForm = persistForm(form);
persist({
store: persistedForm,
key: 'form',
});
Motivation
We all use forms. But often it happens that we fill out the form not right away, but after some time. Or we are in the metro and the connection is not stable. Or maybe we accidentally (or purposefully) reload the page. It would be nice if fields in a form were saved in such cases. For this purpose, some local storages is perfect, for example - localStorage, sessionStorage or storing certain parameters in the URL.
Examples
Effector persistence libraries
Usage