mercredi 4 mars 2020

composition of colorpicker component

I'm writing my own colorpicker component using vanilla js. Which design pattern is better to use for communication between its elements? I think about Observer design pattern, but I don't know how to apply it in this situation.

User can change color value through 3 methods: 1) mousemove on canvas; 2) input; 3) palette of predefined colors.

All methods have common elements to update, but also each method has its own set of elements to update when color is changed. Should I create new ObservableSubject for each method or is there a better solution to compose communication between elements?

Aucun commentaire:

Enregistrer un commentaire