private IJavascriptObject GetMapper(IJavascriptObjectMapper iMapperListener) { _JavascriptMapper.Enqueue(iMapperListener); if (_Mapper != null) { return(_Mapper); } _Mapper = _WebView.Factory.CreateObject(); _Mapper.Bind("Register", _WebView, (e) => { if (_PullNextMapper) { _Current = _JavascriptMapper.Dequeue(); _PullNextMapper = false; } if (_Current == null) { return; } int count = e.Length; var registered = e[0]; switch (count) { case 1: _Current.MapFirst(registered); break; case 3: _Current.Map(e[1], e[2].GetStringValue(), registered); break; case 4: _Current.MapCollection(e[1], e[2].GetStringValue(), e[3].GetIntValue(), registered); break; } }); _Mapper.BindArgument("End", _WebView, (e) => { if (_PullNextMapper) { _Current = _JavascriptMapper.Dequeue(); } _Current?.EndMapping(e); _Current = null; _PullNextMapper = true; }); return(_Mapper); }
public TaskToPromiseHandler(IWebView webView) { _JavascriptObject = webView.Factory.CreateObject(); _JavascriptObject.BindArgument("fulfill", webView, _ => { _Tcs.TrySetResult(null); _JavascriptObject.Dispose(); }); }
public Task RegisterMainViewModel(IJavascriptObject jsObject) { var tcs = new TaskCompletionSource <object>(); _Listener.BindArgument("fulfill", _WebView, _ => { _Logger.Debug("Vue ready received"); tcs.TrySetResult(null); }); var vueHelper = _VueHelper.Value; vueHelper.GetValue("ready").Invoke("then", _WebView, _Listener.GetValue("fulfill")); vueHelper.Invoke("register", _WebView, jsObject, _Listener); return(tcs.Task); }