Exemplo n.º 1
0
        private State[] ComputeStates()
        {
            var newWidgets = _builder.Invoke(_context);

            using (Atom.NoWatch)
            {
                _states = StateUtilities.UpdateChildren(_context, _states, newWidgets);
            }

            // ReSharper disable once CoVariantArrayConversion
            return(_states.ToArray());
        }
Exemplo n.º 2
0
        internal static Atom <IState[]> CreateList(BuildContext context, Func <BuildContext, List <Widget> > builder)
        {
            Assert.IsNull(Atom.CurrentScope);

            var states = new State[0];

            return(Atom.Computed <IState[]>(() =>
            {
                var newWidgets = builder.Invoke(context);
                using (Atom.NoWatch)
                {
                    states = StateUtilities.UpdateChildren(context, states, newWidgets);
                }

                // ReSharper disable once CoVariantArrayConversion
                return states.ToArray();
            }, onInactive: () =>
            {
                foreach (var state in states)
                {
                    StateUtilities.DeactivateChild(state);
                }
            }, requiresReaction: true));
        }