talkjs / talkjs-flutter

Flutter SDK for the TalkJS Chat API
https://talkjs.com
BSD 3-Clause "New" or "Revised" License
9 stars 13 forks source link

Implemented the onLoadingStateChanged callback #4

Closed bugnano closed 2 years ago

bugnano commented 2 years ago

cc @eteeselink

We have an onLoadingStateChanged callback for the ChatBox and ConversationList, so that users can show a placeholder while the WebView (and the iframe) is loading.

I'm using a MutationObserver to see when the iframe is mounted, and I'm firing the loaded event once the iframe is in the loaded state.

bugnano commented 2 years ago

Actually, instead of using MutationObserver, waiting for the mount promise to resolve works as well (maybe the promise is resolved before the load event on the iframe though, but it could still be acceptable)