public async void OnJavaScriptCollectionChanges(JavascriptCollectionChanges changes)
        {
            try
            {
                var jsArray = _JsUpdateHelper.GetCachedFromJsObject <JsArray>(changes.Collection);
                if (jsArray == null)
                {
                    return;
                }

                var collectionChanges = jsArray.GetChanger(changes, _JavascriptToGlueMapper);
                var updater           = await _JsUpdateHelper.EvaluateOnUiContextAsync(() =>
                {
                    collectionChanges.ComputeGlues(_JsUpdateHelper);
                    return(UpdateCollectionAfterJavascriptChanges(jsArray, jsArray.CValue, collectionChanges));
                });

                if (updater?.HasUpdatesOnJavascriptContext != true)
                {
                    return;
                }

                await _JsUpdateHelper.RunOnJavascriptContextAsync(() =>
                                                                  _JsUpdateHelper.UpdateOnJavascriptContext(updater)
                                                                  );
            }
            catch (Exception exception)
            {
                LogJavascriptSetException(exception);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        public void OnJavaScriptCollectionChanges(JavascriptCollectionChanges changes)
        {
            try
            {
                var res = _SessionCache.GetGlobalCached(changes.Collection) as JSArray;
                if (res == null)
                {
                    return;
                }

                var collectionChanges = res.GetChanger(changes, this);

                Context.RunOnUIContextAsync(() =>
                {
                    using (ReListen())
                        using (_ListenerRegister.GetColllectionSilenter(res.CValue))
                        {
                            res.UpdateEventArgsFromJavascript(collectionChanges);
                        }
                });
            }
            catch (Exception e)
            {
                _Logger.Error(() => $"Unable to update ViewModel from View, exception raised: {e.Message}");
            }
        }
Esempio n. 4
0
        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}");
            }
        }
Esempio n. 5
0
        internal CollectionChanges(IJavascriptToCSharpConverter jSCBridgeCache, JavascriptCollectionChanges changes, Type targetedType)
        {
            _IJSCBridgeCache = jSCBridgeCache;
            _TargetedType    = targetedType;

            IndividualChanges = changes.Changes
                                .Select(jvchnage => new IndividualCollectionChange(jvchnage, _IJSCBridgeCache, _TargetedType))
                                .OrderBy(idc => idc, this).ToArray();
        }
Esempio n. 6
0
        public void OnJavaScriptCollectionChanges(JavascriptCollectionChanges changes)
        {
            try
            {
                var res = _SessionCache.GetGlobalCached(changes.Collection) as JSArray;
                if (res == null)
                {
                    return;
                }

                var collectionChanges = res.GetChanger(changes, this);

                Context.RunOnUIContextAsync(() =>
                {
                    UpdateCollection(res, collectionChanges, res.CValue);
                });
            }
            catch (Exception e)
            {
                _Logger.Error(() => $"Unable to update ViewModel from View, exception raised: {e.Message}");
            }
        }
Esempio n. 7
0
 internal CollectionChanges(IJavascriptToCSharpConverter iJSCBridgeCache, JavascriptCollectionChanges changes, Type iTargetedType)
 {
     _IJSCBridgeCache = iJSCBridgeCache;
     _TargetedType    = iTargetedType;
     _Changes         = changes;
 }
Esempio n. 8
0
 internal CollectionChanges(IJavascriptToGlueMapper jsCsBridgeCache, JavascriptCollectionChanges changes, Type targetedType)
 {
     IndividualChanges = changes.Changes
                         .Select(collectionChange => new IndividualCollectionChange(collectionChange, jsCsBridgeCache, targetedType))
                         .OrderBy(idc => idc, this).ToArray();
 }
Esempio n. 9
0
 public Neutronium.Core.Binding.CollectionChanges.CollectionChanges GetChanger(JavascriptCollectionChanges changes, IJavascriptToCSharpConverter bridge)
 {
     return(new Neutronium.Core.Binding.CollectionChanges.CollectionChanges(bridge, changes, _IndividualType));
 }
Esempio n. 10
0
 public CollectionChanges.CollectionChanges GetChanger(JavascriptCollectionChanges changes, IJavascriptToCSharpConverter bridge)
 {
     return(new CollectionChanges.CollectionChanges(bridge, changes, _IndividualType));
 }
Esempio n. 11
0
 public CollectionChanges.CollectionChanges GetChanger(JavascriptCollectionChanges changes, IJavascriptToGlueMapper bridge)
 {
     return(new CollectionChanges.CollectionChanges(bridge, changes, _IndividualType));
 }