Surface / Drawing only what a Message can change

What still draws every time

A drawing is kept only when it is known that nothing it reads was written. Everything else is drawn again:

  • A Message with no Transition. A Machine may hold Transitions for three of your forty Messages. Each of the other thirty-seven draws every Surface, as it does today. The next Message that has a Transition keeps drawings again.
  • A Model track did not see made. The first Model, one your application installs from storage or a server render, or one from an update you did not wrap draws every Surface once. Wrap the outermost update, once.
  • A Surface that reads through a function. A Surface whose model reads with Projection.fromReader, or picks a field with true in Projection.of, names no Model field. Every Message that changes the Model draws such a Surface.
  • A Surface that shows server data through a foldkit-remote read. Such a read does name the field its store sits in, but the store also changes with Remote's own Messages and with any of yours that starts a write, so the field's name is not trusted: every Message that changes the Model draws the Surface, and a panel of server rows is drawn as often as before. This covers a Surface whose model holds the read itself (Data.get, Data.query). A value you derive from one with Projection.derive, or a plain reference to the store's field, is matched by that field like any other, so a Message of yours that has a Transition and also writes the store must declare it.
  • A page rendered on a server, and a view called outside a running application (in a unit test), where no drawing can be kept.

Fields inside a struct match by where they sit. Say the Model has account: { owner, balance }. A Message that sets account draws a Surface that reads account.owner, and one that sets account.owner draws a Surface that reads account. A Message that sets account.balance does not draw the Surface that reads account.owner.

Three rules for the views themselves:

  • A renderer reads only the Model it is given. If it also reads a variable from outside, that variable can change with no Message declared to write it, and the old drawing stays.
  • Each view from writes.rootView stands at one place on the page. For the same Surface in two places, call writes.rootView twice.
  • Call writes.rootView once, at the top of a module, as above. A view made inside another view is new on every render and keeps nothing.