In my redux
app I have some settings that should be persisted to disk when they change (as JSON file) and loaded with the app (to fill the initial state of the store).
I guess app settings are state, so they belong in the store. Then I have actions that modify settings, either like SETTINGS/CHANGE
with payload {name:'settingName', value: 'settingvalue'}
or fine grained like SETTINGS/UNITS
with payload 'metric'
or 'imperial'
.
Now I need something that intercepts certain state changes/action submissions and persist them to disk as serialized JSON. Is this something the settings
reducer should do itself or better some kind of middleware that can perform this async in the background?
How would that look like in code?