Events are always a problem for a Cells-driven model, which being
declarative is more of a steady-state paradigm: each cell rule is
authored in the midset of "if the rest of the world is such and such,
then I am so-and-so".
What I have been seleing as a general solution to the event problem is:
(c? (case (^event)
(this (derive-this self))
(otherwise .cache)))
..where .cache is my current value. ie, as far as this rule is
concerned, any event other than 'this means nothing to me and I wish I
did not even have to worry about it.
The problem I ran into is that my derive-this returned some other model
instance, and as other events ignored by this rule transpired, that
model instance ceased to be. So the slot in question now held a dead
instance and returned it when the slot got queried. This happened in
turn because models are cells-mediated and normally when the instance
ceased to be some dependency would have kicked off the above rule and it
would have returned nil or some new instance, but...
...when some event other than 'this came through, the rule ran and the
cell ended up dependent only on the event cell. Rules depend only on the
things they touched in their last invocation, and when some other event
comes through the only cell touched is the event cell. uh-oh.
What is needed is a cells-aware way of saying I /really/ do not want to
know about other events, and that is the kind of thing I use synapses
for. A synapse is like an flet or labels function, a cell internal to a
rule. I have not bundled up the new synapse to look all clever so a lot
of wiring shows but in the end it will just be something like:
(c? (case (f-find (^event) '(this that))
(this ...)
(that ...)))
...and the rule will fire only when the event is thos or that, meaning
any/all dependencies established during the processing of this or that
will stay around until another event this or that occurs.
kt