HeinrichApfelmus/threepenny-gui — pull request #56 by duplode (2013-10-04 04:46:59+00:00)
Title: Add 'sinkWhen' function for conditionally updating an 'Attribute'.

Inspired by [your minimal widget example](https://gist.github.com/HeinrichApfelmus/6495734); more specifically, by how it disconnects view and model while the user edits. I believe the main selling point of `sinkWhen` is eliminating one reason for using `onChange` directly. The implementation combines boolean and value into a pair to ensure predictable results if both Behaviors change simultaneously (with separate `onChange` handlers for each Behavior, if the boolean changed to `False` at the same time that the value changed then whether the Attribute would be updated would depend on the execution order of the handlers).

P.S.: From reading the Reactive.Threepenny internals, I gather that making a pair in the way I just did is very cheap, as Behaviors synthesized with the `Applicative` instance are not cached. Is that correct?