Reactive programming with Ocsigen


I’m trying to complete the final exercise of:

I have a color picker, built server-side, which gives me a “hsv” signal ( (int * float * float) Eliom_shared.React.S.t). I already have applied a map to this signal in order to have rgb representation. This signal is used client-side to choose the color the pen will draw.

The exercise is to add a button to be able to pick a color on an existing canvas. My idea is to “update” the signal when a color is picked. In this page , I see a function is returned along with the signal in order to do that. But here, the toolkit doesn’t provide such a function.

What can I do?

Hi @sebbes,
I answered to fast, without checking the color-picker function. If the function provides a signal and no setter function, there is no way for you to update this signal. The color picker only seemed to be updated from the graphical interface. The solution I can see that is not a hack, would be to modify the code of the make function to accept an optionnal parameter containing the signal AND the setter so you would have a “custom” signal that you can update by hand.

The code is here.

If the solution fits your need, you can event make a PR on the color picker to improve the current code (I know it is a lot to ask and it’s a shame that the color picker doesn’t already produce this interface)

Otherwise, you could send a click event on the color you are looking for… this is the hack :stuck_out_tongue: