Plz, What's best store design pattern in this case?
I made a simple example code to explain my current situation.
Please see my picture.
I have color property as global, also in pages.
I made getter and setter to change page color.
But if global color is active, The global color should be changed, also should be returned by getter.
Is there other way than better than this?
Now I have only color property, so making setter and getter is not hard.
but I will have much more properties which also has same global properties...
Creating each property setter & getter is really tedious in this case..
3 Replies
You can use a HOF to update each property either on the page or globally:
And a similar function for the getter.
Thanks Alex. It's amazing solution I was look for.... !!! What's is HOF? is it kind of pattern name?
A higher order function (one that returns a function), but I found that pattern, that will do the trick, too