aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-08-26 03:17:09 +0800
committerDan Finlay <dan@danfinlay.com>2016-08-26 03:17:21 +0800
commit6eb09c1a796f636ce45c9589a47a40f37e4ed2ac (patch)
tree34a973a4f78b01bbc2af74e1673a4b7b62639f45 /docs
parentb2233f7e0a6d2596b3fdffe0f0f76bfa58f541f9 (diff)
downloadtangerine-wallet-browser-6eb09c1a796f636ce45c9589a47a40f37e4ed2ac.tar
tangerine-wallet-browser-6eb09c1a796f636ce45c9589a47a40f37e4ed2ac.tar.gz
tangerine-wallet-browser-6eb09c1a796f636ce45c9589a47a40f37e4ed2ac.tar.bz2
tangerine-wallet-browser-6eb09c1a796f636ce45c9589a47a40f37e4ed2ac.tar.lz
tangerine-wallet-browser-6eb09c1a796f636ce45c9589a47a40f37e4ed2ac.tar.xz
tangerine-wallet-browser-6eb09c1a796f636ce45c9589a47a40f37e4ed2ac.tar.zst
tangerine-wallet-browser-6eb09c1a796f636ce45c9589a47a40f37e4ed2ac.zip
Add persistent form class
Diffstat (limited to 'docs')
-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)
+```
+