nuclear-js icon indicating copy to clipboard operation
nuclear-js copied to clipboard

Getters getting triggered on n-dimensional maps

Open pbeets opened this issue 10 years ago • 5 comments

Seems like the refactor of reactor now triggers getters whenever a change happens at the root level.

For ex:

export default {
  getter: [['key1', 'key2', 'key3'], item => item]
}

version 1.1.2 and before, will only get triggered when ['key1', 'key2', 'key3'] has changed.

version 1.2.0 the above getter is triggered when anything in ['key1'] changes. This is undesirable as even if key3 has not been set it will still receive and update a bound state with undefined.

pbeets avatar Nov 04 '15 01:11 pbeets

Hey Pbeets,

Under the hood the getter evaluation mechanism has changed, however it shouldn't be calling a change handler (via observe) unless the value of the getter has changed?

Can you elaborate a bit more on how you are consuming this getter, are you evaluate or observe or using ReactMixin?

This seems like a pretty serious issue to me, it'd be great to have more context.

jordangarcia avatar Nov 04 '15 17:11 jordangarcia

@jordangarcia I'm consuming it via getDatabindings / ReactMixin. However using an observe seems to have the same effect.

The getters are setup before hand so the data it's supposed to get doesn't exist yet.

pbeets avatar Nov 04 '15 18:11 pbeets

What type of data is being returned, you mentioned that it was undefined?

If you could post an example of the store / getter that would help a lot

On Wednesday, November 4, 2015, pbeets [email protected] wrote:

@jordangarcia https://github.com/jordangarcia I'm consuming it via getDatabindings / ReactMixin. However using an observe seems to have the same effect.

— Reply to this email directly or view it on GitHub https://github.com/optimizely/nuclear-js/issues/187#issuecomment-153830646 .

jordangarcia avatar Nov 04 '15 19:11 jordangarcia

Unable to reproduce. Looks like it was a problem on my end.

pbeets avatar Nov 25 '15 06:11 pbeets

@jordangarcia Alright, finally figured out the condition. Looks like for particular set of combine functions, the getter handler is being called regardless.

I've added an example: https://gist.github.com/pbeets/2682c0fb5b8243c165a1

pbeets avatar Nov 26 '15 05:11 pbeets