KartikTalwar / gmail.js

Gmail JavaScript API
MIT License
3.74k stars 455 forks source link

compose event firing before content is ready #715

Closed woniesong92 closed 2 years ago

woniesong92 commented 2 years ago

issue

compose event fires before the content inside the compose element is ready.

repro steps

gmail.observe.on('compose', function (compose, type) {
  console.log(compose.body()) // undefined

  setTimeout(() => {console.log(compose.body())}, 10 * 1000)) // content is ready usually after 10 seconds
}

attempts to fix

josteink commented 2 years ago

Not everyone needs all parts of the compose to be ready when this event fires, so I don't think there's any concrete spec or behaviour we can say is "most correct" here.

Alternatively, I could wait for compose.dom.body() to not be undefined, which works for my usecase.

As such, this would be my suggestion too.