contextual card caching
Idea
+issues
As a developer, it's currently quite difficult to maintain card context across a local request. It would be preferable for developers not to have to carry everything with them, but to have this handled by the fetch mechanism.
+solution
Generally speaking, the default behavior should be for fetch to return the current contextual state of a card, but there should be additional API to inquire into persistent states
Whenever you initialize a card, it should immediately go in the local cache as initialized.
exception: stubs (cards with no name or placeholder name - they should go in when a name is assigned)
any "new" (not real, no id) card in the local cache needs to have one of these three states:
(1) virtual, (2) mock, or (3) unknown.
We know what "virtual" means (structured + new)
A "mock" has been assigned some local meaning (type and/or content).
An "unknown" is a pure placeholder for a name. It is typically initiated just for the sake of making future lookups faster, but it has no real local meaning
There is currently API for "skip_virtual" (eg `fetch name, skip_virtual: true`). Let's change that to: `fetch name, new: false`. The point is to have an API for fetching real and only real cards: it means we shouldn't return any new cards of any sort (none of these three states, which makes it more precise than skip_virtual).
To spell that out a bit more:
fetch name # returns real, virtual, and (existing) mock
fetch name, new: false # returns real
fetch name, new: {} # returns real, virtual, and (new and existing) mock. always returns something
If you update (including by reinitializing??) any card that is already in the current cache, the local cache should be updated.
+discussed in support tickets
+relevant user stories