Tony D’Addeo pfp
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
14 reactions

Tony D’Addeo pfp
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