question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

refresh() should (?) force invoke change event

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:23 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
scarletskycommented, Aug 31, 2022

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. 😄

0reactions
donmccurdycommented, Nov 6, 2022

+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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I programmatically force an onchange event on an ...
Create an Event object and pass it to the dispatchEvent method of the element: var element = document.getElementById('just_an_example'); var event = new ...
Read more >
force:refreshView - Salesforce Lightning Component Library
This example refreshes the view after a server-side action that changes the data is successfully completed. ({ refresh : function(component, event, helper) ...
Read more >
.trigger() | jQuery API Documentation
A call to .trigger() executes the handlers in the same order they would be if the event were triggered naturally by the user: ......
Read more >
Refresh Select2 without triggering change event #3620 - GitHub
In Select2 v4 documentation recommended to reset select by setting value to empty value and triggering event. $('#id').val('').trigger('change').
Read more >
How and when to force a React component to re-render
Forcing an update on a React class component ... In any user or system event, you can call the method this.forceUpdate() , which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found