aboutsummaryrefslogtreecommitdiffstats
path: root/docs/form_persisting_architecture.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/form_persisting_architecture.md')
-rw-r--r--docs/form_persisting_architecture.md23
1 files changed, 22 insertions, 1 deletions
diff --git a/docs/form_persisting_architecture.md b/docs/form_persisting_architecture.md
index 8b5ab495f..9e6cb7c41 100644
--- a/docs/form_persisting_architecture.md
+++ b/docs/form_persisting_architecture.md
@@ -10,5 +10,26 @@ Since:
Whenever this class is loaded, it registers an `onChange` listener. On those events, it checks the target for a special ID attribute it listens for.
-Let's say we call our class `PersistentForm`. So then we might check for a `persistent-form-id`.
+Let's say we call our class `PersistentForm`. So then we might check for a `persistent-form-id` on change.
+
+The parent element will define a special attribute, let's say `persistent-form-parent-id`.
+
+Here's some pseudo-code for it:
+```
+onChange(ev) =>
+ persisted = localStorage[parentKey]
+ persisted[childKey] = ev.value
+ localStorage[parentKey] = persisted
+```
+
+On startup, we just do the inverse:
+
+```
+onStart() =>
+ el = this.getEl()
+ parentKey = el.attr('persistent-form-parent-id')
+ children = el.children.where('[persistent-form-id]')
+ children.each(loadValue)
+```
+