I'm having some trouble comparing the SWidgets examples to the books. Specifically, looking at SLabel
Java source
Typescript source
Operational.updates()
The class begins by immediately creating a listener on Operational.updates(). This is a bit confusing since the book says:
The Sodium-specific primitives updates
and value
both take a cell and give you a
stream. Here are two use cases for this. There aren’t many (some others will come up
in later chapters):
■ You might want to send a cell over a network link. This would require deconstructing
it into its current value and a stream of its updates, and holding the
result on the other end of the wire.
■ In chapter 12, we’ll discuss a function called calm() that for performance reasons
removes unnecessary steps from cells, where the value is a repeat of the
previous firing. You need Operational.updates() to implement it, but it follows
our rule and doesn’t expose the steps to the caller.
Considering this, please clarify why the widgets examples use Operational.updates() if there aren't many use cases?
Is it only to purposefully discard the first event - and otherwise cell.listen() is fine?
Transaction.post()
The class ends with a call to Transaction.post(). What in the world is that?! I don't think it's even mentioned in the book... the comment in the Java class mentions it has something to do with looping, which the book seems to solve with some sort of Lazy primitive.
If I got any of the above wrong - feel free to correct!