Is there a re-frame event triggered when the user navigates away from a panel that I could use to delete the panel’s data from the in-memory DB?
There are no built-in events like this. But you can easily set up an event to be dispatched when you switch panels. That’s how I do it.
Now, for the most reliable and simplest way to purge old data is to consider your in-memory db to be a cache of what’s on the server. Keep a least-recently-used discipline so that you can purge stuff that hasn’t been accessed in a while.
If you store stuff for a view under a particular keyword and purge it after you switch views kind of defeats the purpose. The DB should have a unified view of the data. There is very often more shared between the panels than you might think.
Consistent data across users is more important in my use case than the performance hit from pulling data afresh from the server all the time.
Well, I’d argue that at that point, why not just use a “traditional” web app. Note that these problems of data freshness, synching with the server, and purging are present in every “single page app”. No framework has a real solution to this.
If you reply to this message, how does my in-memory DB pick this change up?
The server needs to notify the client. When the client connect to the server (through websockets or server-sent events), a “subscription” is set up for the data they are looking for. That subscription keeps track of whatever needs to update. In a chat app, you’d keep track of what chatrooms they are in. But it’s totally domain and backend dependent. No solution to this, though GraphQL may make it easier.
Is there a library that could do this, encapsulating the difficulty, without re-fetching the data for the entire discussion
No library. I think it’s very domain-specific, though GraphQL may help. The best patterns that I’ve see rely on very granular updates. So instead of sending the whole Person record when their address changes, you just send the person’s new address.
I hope this discussion helps. You’re asking really deep questions that are past the edge of our abilities to solve in the general case so far. So it sounds like you understand the issues.