Closed minettiandrea closed 3 months ago
We will consider that suggestion. But implementing it might require significant changes in the next version which are under the way. However, there is an alternative approach. By using onbeforechange, you can either return a temporary value or cancel the action and then trigger an API. The promise will subsequently update what is necessary. Essentially, this method allows you to block native updates and instead trigger your custom requirements. For a better understanding, here's a very basic example: https://jsfiddle.net/6j3tfzum/2/.
Additionally, the functionality will be expanded to include plugins in the next version. These plugins will allow for the creation of custom behavior encapsulated within individual plugins. This means that methods like 'onBeforeChange' will be included within the plugin, removing the need to declare events each time.
Hi, I needed to use some async libraries in combination with jspreadsheet, i.e. to do some validation on cell content change, but with the actual API was not possible, so I've tried to implement it and with a small effort I was able to add it to the library, it should be backward compatible.
The only glitch that I found is that by using heavily Promise.resolve when we call
setValue
and just aftergetValue
setting the value is postponed by the event loop so you wont get the expected value (see data.js test) that's why I've added a Promise as return value ofsetValue
if someone really need to know when the value is actually set, but I would argue that even in the previous API that wasn't guaranteed.Hope that my contribution could be helpful and looking forward to integrate jspreadsheet on my project