-
Notifications
You must be signed in to change notification settings - Fork 1
prefs basic
(worked on till 23 Nov 2020)
- The
prefs-rcl
should receive a set of UI validated fields(name, email, password, settings...) - And the received fields should go through some basic validations
- Store the values inside a specific backend (browser index, localstorage and cloud, etc..)
- Values should be retained on every refresh or restart
- As a developer I should be able to pass in the backend functionalities to prefs-rcl.
-
useWritetoFile
is a hook that can get a set of values and function -
useWritetoFile
hook can also take custom backend function code along with set ofkey: key, val: values, backendfn: custom or "localStorageConfig/fsConfig", tag: "signup"
(expects each backend should have set of configs)const localStorageConfig = { type: "localStorage", name: "profile", maxSize: "5MB", }
-
We are just making use of three storage method for demonstration ie,
localStorage, localforage(package that uses indexed db), filesystem
-
useSavetofile
is an example hook which saves the field values, keys on every change of values and retains the initial value on refresh -
useValidator
hook can be a basic backend validator as in this case, it just checks forlocalStorage
key existence
- As a developer creates calls any pref hook with
key: key, value: values, backendfn: custom or "localStorage, fs", tag: "signup"
-
useWritetoFile
hook checks whether its function or not - if it's not a function its should check for which default backend and read the config
- Backend validator if it passes the save to selected backend
- if its a function it should pass through the custom validator and pass in values to the preferred backend function
- if any validation fails it should pass a state of error and specific feedback to the developer
- On every hook call tag is been passed that's linked specific keys and those are saved along with values as an array of multiple keys
__tag_app
: ["profilesetting", "fontsettings"]