Is it possible to expose a state that’s a list/collection of key-value pairs? I’m thinking along the lines of a simple flat JS object with property names and values which the Bubble programmer would access like a “thing” - e.g. “exposed state’s prop1’s value” or some such.
Nothing in the plugin builder or docs seems to suggest this is possible, but I want to make sure I’m not missing something.
These key/value pairs would not be configured in the property editor, but rather generated internally within the plugin.
Unfortunately, I do not believe this is possible even here in 2022. Of course, you can always expose a string of text that is JSON, but actually defining named keys that you can work with in the editor is a no go Wish it was.
Would really like to see the ability to define an array of keys for visual elements. This is possible for Plugin actions but not for visual elements Or am I wrong @cal ?
Strictly speaking, that is true AFAIK. However, a couple solutions have come to light in the 3+ years since this thread was started.
If there are a known limited number of keys, then a custom Bubble type (that’s not tied to the DB) can be defined. This results in the best Bubble developer experience. I’ve used this approach in published plug-ins.
If the key names or number of key/value pairs can vary, a simple “cheater” approach is to publish a list of delimited strings as an exposed state (the 2nd option described here). It makes use of the :split by operator (which wasn’t available at the time this thread was created). It’s super simple and flexible, but it’s not the most elegant approach if you plan to distribute the plugin.
Yes, I’ve seen that technique mentioned elsewhere. However, I’m a bit of a “purist” and don’t like “polluting” my Bubble environment with JS. The only JS in my apps resides inside plug-ins; but that’s just my personal philosophy.