refresh() should (?) force invoke change event
See original GitHub issueI’ve come to a scenario when I’m using global change event
pane.on('change', (e) => {})
since I need to process the input in a bit more advanced way and can’t simply bind to the properties of existing objects, since I’m operating on dynamic array of objects, so I keep the shared values in separate object that I can bind the inputs to and then using for
loops in the event handler to iterate over all the objects in corresponding arrays to actually apply the values.
The problem is - if I create a new array of objects and I want to re-apply all the values there seems to be no way to do so since the refresh()
method invokes ‘change’ event ONLY when there is a change in value - I mean, I understand it’s called ‘change’ for a reason, but for a scenario when I just want to re-apply the values to new set of objects by processing them in global ‘change’ handler there seem to be no straightforward way to do so… Or am I missing something ? If not - I guess such feature called for example forceRefresh()
or refresh( forceUpdate )
(?) would be much welcome for more advanced scenarios like this.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:23 (11 by maintainers)
Top GitHub Comments
Hmm, now I understand how you design tweakpane (or how tweakpane works). Tweakpane is a data-driven UI, providing one-way data binging. It is more like React than Angular and Vue. If so,
setValue
API may not need (although sometimes it is convenient).Just add more examples for
refresh
API in the document may help a lot. 😄+1 for a bit more detail or examples on the ‘refresh manually’ part of the documentation. I recently ran into a surprise finding that when I call
.refresh()
, the change events of all affected controls are fired… I guess that makes sense in retrospect, but it wasn’t what I expected, and caused a subtle problem for my application.