-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Events on root propagate pre-encoded value #36
Comments
If you were to listen for
And because sublevels have their own encodings, they encode data before passing it up to their parent db, which then (also) emits events. So in the above example, What behavior would you like to see? |
The expected behavior for me would be that no matter where I put the put operation, it would result in the same encoding showing up in the event handler. Probably the more expected case would be to see the encoded value |
The problem there is that context matters. If a parent db emits values originating from a sublevel, I want to guarantee that the parent db is able to work with that value (meaning to do additional operations like updating some index). If a sublevel uses |
I understand the conundrum. The problem that I am having is that I would like to process the input the same way no matter if it comes through root or a sublevel 🤔 Maybe best to put the root value-encoding to Short correction btw.: Before I mentioned |
Can you explain the use case?
Another challenge here is that we don't necessarily encode to binary data (unlike similar db interfaces like the hypercore modules). On |
On |
I have a single db that contains the state and results of an long-term execution. This includes open tasks to execute. On start I want to continue with the open tasks, during the execution I want to be able to queue additional tasks. At the moment I have settled on having a sublevel db and make sure that this works but it feels dangerous to forget about this limitation in future refactorings.
Huh, another surprise. 🤯 Well, i guess nothing is as easy as it seems 😅 . It seems to me like this may be an aspect worth to expose in a more verbose fashion. A simple way to resolve this may be to just note in the documentation about the behavior when using sublevel API's as it was really unexpected to me. |
After spending a little more time with this I am also surprised that // listen(level, event, normalizedValueType, handler)
const unlisten = listen(db, 'put', 'uint8', (key, value) => {}) That listens both put & batch events and makes sure that - no matter the platform - the value type is of the same type. |
Currently, because the events don't use encoded values, I consider that to be an internal detail. And to some extent, directly using a db that has sublevels (as opposed to only interfacing with the sublevels) implies that you're willing to deal with the internals of sublevels (which includes prefixed keys, as well as this encoding story).
👍
Let's discuss that in a new issue |
The events propagated on sub-level instances do not have their value encoded, unlike events triggered by sublevel pushes.
Is this correct behavior?
The text was updated successfully, but these errors were encountered: