Change() Operator, not sure how it works

Can someone explain the ‘changed([scope])’ operator? How does it work? What triggers it?

Do you mean changed([scope])?

1 Like

yes…it is not clear what triggers this. If any value in an attribute of a note is changed, would this trigger the changed and then an update of the note? Or, when someone leaves the note, e.g. the proposed addition of an $OnLeave, attribute.

Yes, the user calls it. It is a deliberate user trigger, like clicking the view tab to ‘force refresh’ the UI. Does that help?

1 Like

Not really? I don’t understand how it is triggered. Put it in a rule? I’m not sure of the timing of the trigger.

Sure. It is 'just" an action code call so is run once but once everytime that action containing it is run. So compare use in a rule vs. a stamp. In the first case it is called every time the rule runs, in the latter once per use of the stamp.

Were the, as discussed in the current meet-up, a notion of events then changed() might be closer to what you want. Events are interesting for at first sight we might assume it is arrival (selection?) and departure (de-selection?) that we are talking about. I suspect, with reflection it might be more nuanced. There’s an interesting feature request to work up here (ofc, ROI may make it not implementable. Still, I think the thought experiment is worthwhile.

In short what are event are we signalling and why?

It’s typically part of an action, such as a rule, edict, or stamp. Often, when an action changes something that’s visible in the view, the view is redrawn automatically. Occasionally, though, one of the less commonly-used attributes doesn’t redraw the display; changed(); reminds Tinderbox to redraw the note whether it thinks it needs to or not.