Exemplo n.º 1
0
        protected override async ValueTask <bool> TryInvokeAsync(ObservableCollectionItemsChangedArgs e)
        {
            if (consumer == null)
            {
                return(false);
            }

            if (!consumer.IsAlive())
            {
                return(true);
            }

            if (e.ObservableCollection.ElementType == typeof(Task))
            {
                foreach (var task in e.ItemsAdded.Cast <Task>())
                {
                    _ = task.ContinueWith(t => {
                        consumer?.ForceUpdate();
                    });
                }
                return(true);
            }

            if (e.NewCount != e.OldCount || e.ItemsAdded.Any() || e.ItemsRemoved.Any())
            {
                await consumer.ForceUpdate();

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        protected async override ValueTask <bool> TryInvokeAsync(ComputedValueChangedArgs e)
        {
            if (consumer == null)
            {
                return(false);
            }

            if (!consumer.IsAlive())
            {
                return(true);
            }

            await consumer.ForceUpdate();

            return(true);
        }
        protected override async ValueTask <bool> TryInvokeAsync(ObservablePropertyStateChangedArgs e)
        {
            if (!consumer.IsAlive())
            {
                return(true);
            }

            IObservableProperty observableProperty = e.ObservableProperty;
            string propertyName = e.PropertyInfo.Name;

            if (observableContainers.TryGetValue(observableProperty, out IObservableContainer container))
            {
                if (container.IsSubscribed(propertyName))
                {
                    await consumer.ForceUpdate();

                    return(true);
                }
            }

            return(false);
        }