Exemplo n.º 1
0
 void IAtomCallbacks.OnInactive()
 {
     foreach (var state in _states)
     {
         StateUtilities.DeactivateChild(state);
     }
 }
Exemplo n.º 2
0
        internal static Atom <IState> Create(BuildContext context, WidgetBuilder builder)
        {
            Assert.IsNull(Atom.CurrentScope);

            State state = null;

            return(Atom.Computed <IState>(() =>
            {
                var newWidget = builder(context);
                using (Atom.NoWatch)
                {
                    state = StateUtilities.UpdateChild(context, state, newWidget);
                }

                return state;
            }, onInactive: () => StateUtilities.DeactivateChild(state), requiresReaction: true));
        }
Exemplo n.º 3
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));
        }