示例#1
0
        public void Loop(Cell <T> c) =>
        TransactionInternal.Apply(
            (trans, _) =>
        {
            lock (this.isLoopedLock)
            {
                if (this.isLooped)
                {
                    throw new InvalidOperationException("Loop was looped more than once.");
                }

                this.isLooped = true;
            }

            if (trans != this.transaction)
            {
                this.transaction = null;

                throw new InvalidOperationException(
                    "Loop must be looped in the same transaction that it was created in.");
            }

            this.transaction = null;

            this.Loop(trans, c);

            return(UnitInternal.Value);
        },
            false);
示例#2
0
        internal Behavior(Stream <T> stream, T initialValue)
        {
            this.stream            = stream;
            this.valueProperty     = initialValue;
            this.UsingInitialValue = true;

            this.streamListener = TransactionInternal.Apply(
                (trans1, _) =>
                this.stream.Listen(
                    Node <T> .Null,
                    trans1,
                    (trans2, a) =>
            {
                this.valueUpdate.MatchNone(
                    () =>
                {
                    trans2.Last(
                        () =>
                    {
                        this.valueUpdate.MatchSome(v => this.ValueProperty = v);
                        this.valueUpdate = MaybeInternal.None;
                    });
                });

                this.valueUpdate = MaybeInternal.Some(a);
            },
                    false),
                false);
        }
示例#3
0
        internal Cell(Behavior <T> behavior)
        {
            this.BehaviorImpl = behavior;

            this.updates = new Lazy <Stream <T> >(() => TransactionInternal.Apply(
                                                      (trans, _) => this.BehaviorImpl.Updates().Coalesce(trans, (left, right) => right),
                                                      false));
        }
示例#4
0
 internal static Behavior <T> ConstantLazyImpl <T>(Lazy <T> value) =>
 TransactionInternal.Apply((trans, _) => StreamInternal.NeverImpl <T>().HoldLazyInternal(trans, value), false);
示例#5
0
 internal static Cell <T> ConstantLazyImpl <T>(Lazy <T> value) =>
 TransactionInternal.Apply((trans, _) => new Cell <T>(StreamInternal.NeverImpl <T>().HoldLazyInternal(trans, value)), false);
示例#6
0
 internal IWeakListener ListenWeakImpl(Action <T> handler) => TransactionInternal.Apply(
     (trans, _) => this.BehaviorImpl.Value(trans).ListenWeakImpl(handler),
     false);
示例#7
0
 internal static Stream <T> UpdatesImpl <T>(Behavior <T> b) => TransactionInternal.Apply(
     (trans, _) => b.Updates().Coalesce(trans, (left, right) => right),
     false);
示例#8
0
 internal static Stream <T> ValueImpl <T>(Behavior <T> b) => TransactionInternal.Apply((trans, _) => b.Value(trans), false);
        internal static Stream <T> MergeImpl <T, T2>(this IEnumerable <T2> s, Func <T, T, T> f) where T2 : Stream <T>
        {
            IReadOnlyList <Stream <T> > v = s.ToArray();

            return(TransactionInternal.Apply((trans, _) => Merge(trans, v, 0, v.Count, f), false));
        }
示例#10
0
 internal Stream <T> MergeImpl(Stream <T> s, Func <T, T, T> f) => TransactionInternal.Apply((trans, _) => this.Merge(trans, s, f), false);
示例#11
0
 internal Cell <T> HoldLazyImpl(Lazy <T> initialValue) =>
 TransactionInternal.Apply((trans, _) => new Cell <T>(this.HoldLazyInternal(trans, initialValue)), false);
示例#12
0
 internal IWeakListener Listen(Node target, Action <TransactionInternal, T> action) => TransactionInternal.Apply(
     (trans1, _) => this.Listen(target, trans1, action, false),
     false);