Tony D’Addeo
@deodad
ended up using MessageChannel and satisfied with the result the MessagePort interface turned out to be an elegant way to avoid race conditions around loading + initialization since it has a queue built in both sides can start send / receive messages when they are ready
1 reply
0 recast
15 reactions
Tony D’Addeo
@deodad
handshake: - root origin sets up MessageChannels are can immediately start sending messages to them - add message event listener on top level document looking for init message from wallet origin - load wallet origin in iframe - add message event listener on local document looking for init response with transferred ports - post init message to root origin - root origin transfers ports from message channels to wallet origin - continue with initialization logic and when ready to start processing messages start the port communication lifecycle is decoupled from iframe loading and initialization lifecycle
2 replies
0 recast
5 reactions
will
@w
I assume this code will be open sourced with the rest of the client eventually?
1 reply
0 recast
1 reaction
Tony D’Addeo
@deodad
yes
1 reply
0 recast
1 reaction
Tony D’Addeo
@deodad
if there's something specific you want to see DM me
1 reply
0 recast
1 reaction
will
@w
appreciate it -- nothing immediate, but hopefully in the next ~month we'll kick off a web connect feature for Teams that will need this or postMessage
0 reply
0 recast
1 reaction