private async Task UpdateOnJavascriptContextWithMapping(BridgeUpdater updater, IJsCsGlue value) { _BuilderStrategy.UpdateJavascriptValue(value); await InjectInHtmlSession(value); updater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }
public async void OnJavaScriptCollectionChanges(JavascriptCollectionChanges changes) { try { var res = _SessionCache.GetCached(changes.Collection) as JsArray; if (res == null) { return; } var collectionChanges = res.GetChanger(changes, this); var updater = new BridgeUpdater(_SessionCache); await Context.RunOnUiContextAsync(() => { UpdateCollection(res, res.CValue, collectionChanges, updater); }); if (!updater.HasUpdatesOnJavascriptContext) { return; } await Context.RunOnJavascriptContextAsync(() => { updater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }); } catch (Exception exception) { LogJavascriptSetException(exception); } }
public async void OnJavaScriptCollectionChanges(JavascriptCollectionChanges changes) { try { var res = _SessionCache.GetCached(changes.Collection) as JSArray; if (res == null) { return; } var collectionChanges = res.GetChanger(changes, this); var updater = new BridgeUpdater(); await Context.RunOnUIContextAsync(() => { UpdateCollection(res, res.CValue, collectionChanges, updater); }); if (!updater.HasUpdatesOnJavascriptContext) { return; } await Context.RunOnJavascriptContextAsync(() => { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); }); } catch (Exception e) { _Logger.Error(() => $"Unable to update ViewModel from View, exception raised: {e.Message}"); } }
private Task UpdateFromCSharpChanges(Func <BridgeUpdater> updaterBuilder, bool needToCheckListener) { CheckUIContext(); BridgeUpdater updater = null; using (var relisten = needToCheckListener ? ReListen(): null) { updater = Update(updaterBuilder, relisten); } if (!updater.HasUpdatesOnJavascriptContext) { return(TaskHelper.Ended()); } return(RunInJavascriptContext(() => { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); })); }
private Task <IJSCSGlue> UpdateFromCSharpChanges(object newCSharpObject, Func <IJSCSGlue, BridgeUpdater> updaterBuilder) { CheckUIContext(); var value = _JSObjectBuilder.Map(newCSharpObject); if (value == null) { return(null); } BridgeUpdater updater = null; using (var relisten = value.IsBasicNotNull()? null : ReListen()) { updater = Update(() => updaterBuilder(value), relisten); } if (!_IsLoaded) { return(Task.FromResult(value)); } return(RunInJavascriptContext(async() => { _BuilderStrategy.UpdateJavascriptValue(value); if (_Context.JavascriptFrameworkIsMappingObject) { await InjectInHTMLSession(value); } updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); return value; })); }
private void RunUpdaterOnJsContext(BridgeUpdater updater) { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater); }
private void UpdateOnJavascriptContext(BridgeUpdater updater, IJsCsGlue value) { _BuilderStrategy.UpdateJavascriptValue(value); updater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }
public async void OnJavaScriptObjectChanges(IJavascriptObject objectchanged, string propertyName, IJavascriptObject newValue) { try { var currentfather = _SessionCache.GetCached(objectchanged) as JsGenericObject; if (currentfather == null) { return; } var propertyUpdater = currentfather.GetPropertyUpdater(propertyName); if (!propertyUpdater.IsSettable) { LogReadOnlyProperty(propertyName); return; } var targetType = propertyUpdater.TargetType; var glue = GetCachedOrCreateBasic(newValue, targetType); var bridgeUpdater = new BridgeUpdater(_SessionCache); await Context.RunOnUiContextAsync(() => { using (_ListenerRegister.GetPropertySilenter(currentfather.CValue, propertyName)) { var oldValue = propertyUpdater.GetCurrentChildValue(); try { propertyUpdater.Set(glue.CValue); } catch (Exception exception) { LogSetError(propertyName, targetType, glue.CValue, exception); } var actualValue = propertyUpdater.GetCurrentChildValue(); if (Object.Equals(actualValue, glue.CValue)) { var old = currentfather.UpdateGlueProperty(propertyUpdater, glue); bridgeUpdater.Remove(old); bridgeUpdater.CleanAfterChangesOnUiThread(_ListenerRegister.Off); return; } if (!Object.Equals(oldValue, actualValue)) { OnCSharpPropertyChanged(currentfather.CValue, new PropertyChangedEventArgs(propertyName)); } } }); if (!bridgeUpdater.HasUpdatesOnJavascriptContext) { return; } await Context.RunOnJavascriptContextAsync(() => { bridgeUpdater.UpdateOnJavascriptContext(Context.ViewModelUpdater); }); } catch (Exception exception) { LogJavascriptSetException(exception); } }
public void UpdateOnJavascriptContext(BridgeUpdater updater) { updater.UpdateOnJavascriptContext(_Context.ViewModelUpdater, _SessionCache); }