Three Layer Storage

I have improved some code paths in pageHandler but there are many opportunities for simplification remaining. I have worked slowly here because many cases have order sensitivities due to the compounding of function. github

I would like to separate these functions into several layers where they can be inspected for correctness and more easily accommodate extension. These layers might be:

one

handles storage and dom journal actions

two

handles gets and puts

handles explicit and implicit forks

handles successful and failed puts

three

handles origin (ajax) and local storage

exposes permissions and login state

data

The page data could move smoothly up and down this stack. However there is some situational awareness and some exception handing that must move up and down the stack too. I've yet to find the inspiration that would keep the one layer we already have from becoming three layers of equally brittle code. Accumulating experience can help. Auto-quoting the BBC is one more case to think about.

save ⇒ editor ⇒ policy ⇒ store

link ⇒ policy ⇒ store ⇒ policy ⇒ refresh

add ⇒ editor ⇒ policy ⇒ store ⇒ ⇒ refresh

See Page Storage Abstraction for earlier thinking.