Maybe there’s some way of doing this, not sure. But if you’ve got some function that returns HTML, and use it like [fn()]
in your HTML, then use update()
, that function will be called again, right? There’s no way of blocking that, as far as I know–which could do things like reset state and such.
Not even sure how you’d implement such a feature. Maybe pass an argument to the function telling it it’s updating or something? Or mark the code as only-run-once somehow? [:code run once]
? Not sure… Could be useful for certain plug-ins though to avoid users of the plugin accidentally messing it up by using update()
.
Ooh, an interesting plugin! It doesn’t work in the way I’m talking about at all though.
The function would need to be able to generate some return value when called. But always return that same return value for that source call every time, so that when
update()
is called on an element that contains code that calls the function… it’s as if that code block was not re-evaluated at all.That tap plugin specifically does not use
update()
at all. And specially does generate new values when it’s interacted with. I’m not sure how it’s relevant. Maybe you could point me to the part you think is doing what I’m talking about?Maybe the
locker-plugin
might be a better example. It essentially stores the ‘locked’ value, so whenupdate()
is used, it would only return the ‘locked’ value.Ah I see, that seems to work about as expected. Only annoyance is, the user of the plugin has to come up with a unique name and track those, make sure they don’t use the same name twice or whatever.
This method would work, which is cool. I still feel like it would be a useful feature for the engine anyway. If only to save on processing those code blocks that the user only wants to “run once.”