void IAtomCallbacks.OnInactive() { foreach (var state in _states) { StateUtilities.DeactivateChild(state); } }
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)); }
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)); }