Hey @NigelG, it’s only through building plugins that these edge cases become obvious. There are some bugs in instance.publishState() that make them obvious. You can test this for yourself.
Consider the following: let’s say I have a new custom datatype (aThing) called “Favorite Thing. A Favorite Thing has two fields on it - a Name (text) and a Value (number).
And now I create 10 Favorite Things, all of which have Names, but only one of which has a Value assigned.
If I “Do a Search for…” all Favorite Things and ask :each item’s Value, what do I get?
Well, we will get a list of number type where all of the Values are null, except for the one that is populated. So a list like:
null, null, null, null, null, null, 7.77, null, null, null
Null is not a number, it is an empty array element.
Cool. It is what it is. Well, if I try to pass this array into a plugin and then publish that same numeric array to a numeric list output, the publishState() function will throw an error.
It will basically tell me that all of the values in the array, except for the item at index 7, are invalid. That is, type constraints are enforced for the Bubble plugin developer, but not for native Bubble.
So, if I want to publish this list, I have to replace the nulls (which are a special object that denotes “empty”) with some number. We’d obviously pick 0 as this is how JavaScript handles the numeric equivalence of null.
Some other types of Bubble lists can in fact have null values. Things for example are one. If I have a list of Things, and some position in the list is empty (that is, there is no Thing there), I can in fact just use null to indicate that there is no Thing at that position in the list.
But in the case of dates (as an example similar to numbers), null is not supported. If I want to indicate that some position in a list of dates is empty, I have to pick some arbitrary date that represents empty (in my plugins I represent this as the JavaScript minimum date).
Now all this is obviously a bug. (Dates are objects and Things are objects but a list of Things supports null entries, while a list of dates does not, etc, etc.) But it’s freaking annoying to deal with. (Note that I am the only plugin dev in all of Bubble-dom that understands this and builds Bubble plugins that can deal with these idiosyncrasies, but I’ve pointed them out and they’re no secret.)