SodiumFRP / sodium

Sodium - Functional Reactive Programming (FRP) Library for multiple languages
http://sodium.nz/
Other
848 stars 138 forks source link

Fix Send allowed in Operator #163

Closed jam40jeff closed 5 years ago

jam40jeff commented 5 years ago

The following code should throw an exception but does not:

StreamSink<int> s = Stream.CreateSink<int>();
Cell<int> c = Cell.Constant(0);
c.Map(_ =>
    {
        s.Send(0);
        return Unit.Value;
    }).Listen(_ => { });

The problem is that the code to check if Send was called within a Transaction doesn't apply for the first value created from a Cell (through HoldLazyInternal via LazyBehavior). LazyBehavior needs to guard against Send in its initial value creation just like Transaction.Prioritized does.