Akshay
Akshay2y ago

Mutating mo.ui.dictionary objects?

I added one more cell that shows how to build a markdown-based UI based on the UI elements in the dictionary. It uses a private API, but we can provide a public API for this soon.
6 Replies
ztawil
ztawil2y ago
Thanks Akshay, this is really cool and helpful. I might be having a brainfart, but I can't figure out how to add to the dictionary after it's been created:
ztawil
ztawil2y ago
No description
ztawil
ztawil2y ago
My assumption is after the second cell runs the first cell thinks the dictionary has been affected so it re-runs thereby overwriting the changes of the first. My use case is I'm dynamically pulling data from an API to label. After getting so many good labels, I use that info to re-run the API search and continue labeling might be easier to debug together (if you are up for it)
Akshay
AkshayOP2y ago
Thanks for the extra context, that's helpful. Like most things in marimo, mo.ui.dictionary doesn't support mutation. You can get very far with pure DAGs, but sometimes you do need state. I'm down to debug together --- we can see whether this is one of those cases where we can get away without mutation, or whether we really do need mutable state
ztawil
ztawil2y ago
Yeah, agree. I might just be rabbit holed into what I think is the solution. I'll suggest some times next week probably?
Akshay
AkshayOP2y ago
Sounds good! Let's follow-up over DM.