-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
Creating apps that use the KV store is a bit too cumbersome.
- It requires having pubsub listeners in different files
- It requires complex handlers that take
onConflictparameters andetagstuff, e.g.const getUpdatedUnreadMessages = ({ currentData = {}, etag } = {}) => { - We're currently adding multiple selectors for every type of KV we are manipulating
Solution
We want a very simple API that is super easy to use for handling KV updates that uses Chelonia to automatically decide where in the state these keys are stored, and creates a simple API for creating updates and handling conflicts.
See okTurtles/group-income#2903 for details.
Also see the convenience function updateKVPreferences from Sebin's recently merged PR in identity-kv.js.
The user should not be responsible for anything related to pubsub events when dealing with KV stuff.
The pubsub KV logic could still be available for more complicated use-cases.
EDIT: since we would be moving most of the contract actions into the KV store (e.g. state.attributes) we should also think about how this new friendlier KV API would handle validation. So we could for example say that "whenever this key is validated please use this zod schema to validate".