コード例 #1
0
        internal static Stream <T> SwitchSImpl <T, T2>(this Behavior <T2> bsa) where T2 : Stream <T>
        {
            return(TransactionInternal.Apply(
                       (trans1, _) =>
            {
                Stream <T> @out = new Stream <T>(bsa.KeepListenersAlive);
                MutableListener currentListener = new MutableListener();

                void HInitial(TransactionInternal trans2, Stream <T> sa)
                {
                    IListener cl = currentListener;
                    cl.Unlisten();

                    currentListener.SetListenerImpl(sa.Listen(@out.Node, trans2, @out.Send, false));
                }

                void H(TransactionInternal trans2, Stream <T> sa)
                {
                    trans2.Last(
                        () =>
                    {
                        IListener cl = currentListener;
                        cl.Unlisten();

                        currentListener.SetListenerImpl(sa.Listen(@out.Node, trans2, @out.Send, true));
                    });
                }

                trans1.Prioritized(new Node <T>(), trans2 => HInitial(trans2, bsa.SampleNoTransaction()));
                IListener l1 = bsa.Updates().Listen(new Node <T>(), trans1, H, false);
                return @out.UnsafeAttachListener(l1).UnsafeAttachListener(currentListener);
            },
                       false));
        }
コード例 #2
0
 internal static Stream <T> UpdatesImpl <T>(Behavior <T> b) => TransactionInternal.Apply(
     (trans, _) => b.Updates().Coalesce(trans, (left, right) => right),
     false);