hftf / coords

2 stars 1 forks source link

Update overlaps when a checkbox is clicked #31

Closed hftf closed 10 years ago

MattiasBuelens commented 10 years ago

It comes down to adding this snippet in the right place:

if(this.state.coords.length) {
    list_overlaps(this.state.coords);
}

Problem is where exactly this should go. You can do it in setState, but then you're doing too much work when a whole menu is rotated (rotateStates) or when loading state from the URL (setAll). Ideally, you want to call it at most once per trigger...

hftf commented 10 years ago

How about a new method that takes care of everything (list_overlaps and replaceState) at the end of a “transaction”?

MattiasBuelens commented 10 years ago

Sounds reasonable. Make State use private functions to do individual operations (changing the state of one or more inputs, updating the URL,...) and expose public functions which use these individual operations and afterwards call the private "transaction finalizer".

We'll need a bit of refactoring to make sure the callers can do everything in one transaction. For example, reset_all in coords.js currently calls State functions multiple times, ideally we want to reduce that to just one transaction call.

hftf commented 10 years ago

:+1: