Skip to main content
Answered

Pass a long string to modal


Dear miro team,

I have to pass a long string to a modal when it’s being open. The app is supposed to run at client side only, and wrigin the string to board, then reading it from the modal is not a good option.

This is the sudo code:

`miro.board.ui.openModal('./editor.html', { dataToBePassedToModal: text })`

Is that possible?

Best answer by Daniela Gavidia

Hello Mohsen,

 

As you have already noticed, the openModal method in the SDK does NOT support passing data. You can use board metadata to store the string there and then read it from the modal:

Write to the board metadata:

await miro.board.metadata.update({'<YOUR_APP_ID>': {"data": "hello"}}

Read from the board metadata:

await miro.board.metadata.get() 

 

Another option would be to use the broadcastData() method:
https://developers.miro.com/docs/the-windowmiro-object#section-broadcast-data
and the listen to the BROADCAST_DATA event:
https://developers.miro.com/docs/namespace-sdk#section-event-type
 

However, the BROADCAST_DATA event is experimental and I have found it to not be very reliable. We are in the process of building a more robust solution.

 

I hope this helps.

 

Daniela

View original
Was it helpful?

3 replies

Daniela Gavidia
Mironeer
Forum|alt.badge.img

Hello Mohsen,

 

As you have already noticed, the openModal method in the SDK does NOT support passing data. You can use board metadata to store the string there and then read it from the modal:

Write to the board metadata:

await miro.board.metadata.update({'<YOUR_APP_ID>': {"data": "hello"}}

Read from the board metadata:

await miro.board.metadata.get() 

 

Another option would be to use the broadcastData() method:
https://developers.miro.com/docs/the-windowmiro-object#section-broadcast-data
and the listen to the BROADCAST_DATA event:
https://developers.miro.com/docs/namespace-sdk#section-event-type
 

However, the BROADCAST_DATA event is experimental and I have found it to not be very reliable. We are in the process of building a more robust solution.

 

I hope this helps.

 

Daniela


  • Author
  • Beginner
  • 4 replies
  • April 29, 2021

Thank you Daniela,

Unfortunately await miro.board.metadata.get() is also experimental. Since I’m building a production ready app I can’t use something that may change at any moment.

The the interactions of my users require a large screen, so I really need to open modal, and I have to pass the data to the modal,.. I got stuck here. 

 


  • Author
  • Beginner
  • 4 replies
  • April 29, 2021

Oh I realized that writing to metadata and then reading it from modal is prone to concurrency issues.:sob: