This PR implements the token and tokenFetcher properties for the Session.
tokenFetcher works in the following way (See webview_common.dart):
In the JS side I create 2 global variables: tokenFetcherPromise and tokenFetcherResolve, that are the promise that will be awaited in the tokenFetcher callback, and the resolve function for that promise.
The tokenFetcher callback in the JS side emits the JSCTokenFetcher event, that will be handled in Dart.
In session.dart, chatbox.dart and conversationlist.dart the _jscTokenFetcher callback calls the tokenFetcher callback provided by our users, and uses its return value to resolve the tokenFetcherPromise by calling tokenFetcherResolve via JS.
Going back to webview_common.dart, on the JS side, a new tokenFetcherPromise and a new tokenFetcherResolve global variables are created, so that at the next callback we don't have an already resolved promise.
See https://talkjs.slack.com/archives/C05N5AYM353/p1717684182658149 for more details.
This PR implements the
token
andtokenFetcher
properties for the Session.tokenFetcher
works in the following way (Seewebview_common.dart
):tokenFetcherPromise
andtokenFetcherResolve
, that are the promise that will be awaited in thetokenFetcher
callback, and the resolve function for that promise.tokenFetcher
callback in the JS side emits theJSCTokenFetcher
event, that will be handled in Dart.session.dart
,chatbox.dart
andconversationlist.dart
the_jscTokenFetcher
callback calls thetokenFetcher
callback provided by our users, and uses its return value to resolve thetokenFetcherPromise
by callingtokenFetcherResolve
via JS.webview_common.dart
, on the JS side, a newtokenFetcherPromise
and a newtokenFetcherResolve
global variables are created, so that at the next callback we don't have an already resolved promise.Note that this still needs testing.