Can I return a Bubble object client-side?

I’ve seen several threads around this topic but honestly still have no clear idea of how to do this.

My plugin passes in a list of things with custom type which is defined by the user. I would like to publish that exact list to the elements custom state. What is the correct code / format to pass to Bubble? I thought it would be as simple as:

instance.publishState(“myList”, properties.ListSupplied);

The custom state is typed to match the input list type.

Thanks for any help.
Rob.

Can you share screenshot of your plugins settings?

You’ll have to first get the list and in each item get() the unique ID of these things, and then publish their unique ID. That’s what Bubble consider a “thing”. Let us know if that helped and share more details if not (:

4 Likes

Vini, you legend, thanks.

I should have guessed it was the reference to the object rather than trying to pass the whole object back :sweat_smile:

Cheers

1 Like

This is what I have on one of my plugins to process a list, there are other ways offcourse. @vini_brito What do you think of doing it this way?

Screenshot - 2021-03-18T215229.043

2 Likes

Had no problem running this in the “update” function. However when I try to run it in the “initialiseState” function nothing gets returned / displayed front-end. Does this look correct?

@nocodeventure If it works, it works :yum:
Are you dealing with Bubble objects? I don’t see the get() function being used

@robhblake Glad it worked! Try console.log()'ing the “properties.list” to see what comes from it.
Also, try looking for any errors thrown in the console.

1 Like

It works extremely fast :sweat_smile:

1 Like

Thanks Vini. Not sure what was going on there, I just instantiated it in the update function instead.

Any idea why Bubble has a hard time accepting an array of objects as text - have you come across this type of behavior in your adventures?

image

The “array_sent” looks alright … right? The error gets thrown when I try to publishState (type: list of texts). This is the type of output I get:

image

Any thoughts?

Fixed now. I was trying to pass this into a list of texts custom state, whereas it should be single text.

1 Like