Example #1
0
        internal Stream <TResult> SnapshotImpl <T1, TResult>(Behavior <T1> b, Func <T, T1, TResult> f)
        {
            Stream <TResult> @out = new Stream <TResult>(this.KeepListenersAlive);
            IListener        l    = this.Listen(@out.Node, (trans2, a) => @out.Send(trans2, f(a, b.SampleNoTransaction())));

            return(@out.UnsafeAttachListener(l));
        }
Example #2
0
        internal Stream <TResult> MapImpl <TResult>(Func <T, TResult> f)
        {
            Stream <TResult> @out = new Stream <TResult>(this.KeepListenersAlive);
            IListener        l    = this.Listen(@out.Node, (trans2, a) => @out.Send(trans2, f(a)));

            return(@out.UnsafeAttachListener(l));
        }
Example #3
0
        internal Stream <T> Coalesce(TransactionInternal trans1, Func <T, T, T> f)
        {
            Stream <T> @out = new Stream <T>(this.KeepListenersAlive);
            Action <TransactionInternal, T> h = CoalesceHandler.Create(f, @out);
            IListener l = this.Listen(@out.Node, trans1, h, false);

            return(@out.UnsafeAttachListener(l));
        }
        internal static Stream <T> FilterMaybeImpl <T, TMaybe>(this Stream <TMaybe> s, Action <TMaybe, Action <T> > matchSome)
        {
            Stream <T> @out = new Stream <T>(s.KeepListenersAlive);

            IListener l =
                s.Listen(
                    @out.Node,
                    (trans2, a) => matchSome(a, v => @out.Send(trans2, v)));

            return(@out.UnsafeAttachListener(l));
        }
Example #5
0
        internal Stream <T> FilterImpl(Func <T, bool> predicate)
        {
            Stream <T> @out = new Stream <T>(this.KeepListenersAlive);
            IListener  l    = this.Listen(
                @out.Node,
                (trans2, a) =>
            {
                if (predicate(a))
                {
                    @out.Send(trans2, a);
                }
            });

            return(@out.UnsafeAttachListener(l));
        }
Example #6
0
        internal static Stream <T> SplitImpl <T, TCollection>(Stream <TCollection> s)
            where TCollection : IEnumerable <T>
        {
            Stream <T> @out = new Stream <T>(s.KeepListenersAlive);
            IListener  l1   = s.Listen(
                new Node <T>(),
                (trans, aa) =>
            {
                int childIx = 0;
                foreach (T a in aa)
                {
                    trans.Split(childIx, trans1 => @out.Send(trans1, a));
                    childIx++;
                }
            });

            return(@out.UnsafeAttachListener(l1));
        }
Example #7
0
        private Stream <T> Merge(TransactionInternal trans, Stream <T> s)
        {
            Stream <T> @out  = new Stream <T>(this.KeepListenersAlive);
            Node <T>   left  = new Node <T>();
            Node <T>   right = @out.Node;

            (bool changed, Node <T> .Target nodeTarget) = left.Link(trans, (t, v) => { }, right);
            if (changed)
            {
                trans.SetNeedsRegenerating();
            }

            Action <TransactionInternal, T> h = @out.Send;
            IListener l1 = this.Listen(left, h);
            IListener l2 = s.Listen(right, h);

            return(@out.UnsafeAttachListener(l1)
                   .UnsafeAttachListener(l2)
                   .UnsafeAttachListener(ListenerInternal.CreateFromNodeAndTarget(left, nodeTarget)));
        }
Example #8
0
        internal Stream <TResult> SnapshotImpl <T1, T2, T3, T4, TResult>(
            Behavior <T1> b1,
            Behavior <T2> b2,
            Behavior <T3> b3,
            Behavior <T4> b4,
            Func <T, T1, T2, T3, T4, TResult> f)
        {
            Stream <TResult> @out = new Stream <TResult>(this.KeepListenersAlive);
            IListener        l    = this.Listen(
                @out.Node,
                (trans2, a) => @out.Send(
                    trans2,
                    f(
                        a,
                        b1.SampleNoTransaction(),
                        b2.SampleNoTransaction(),
                        b3.SampleNoTransaction(),
                        b4.SampleNoTransaction())));

            return(@out.UnsafeAttachListener(l));
        }