Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a canvas library fit in the Flux Pattern and React?

I like how Flux focuses on a separation of concerns and a unidirectional data flow, but this also makes me wonder how i should incorporate a canvas library like fabricJS.

FabricJS creates a object model on a native canvas element to extend and simplify functionality. My question is whether to initialize a FabricJS canvas element in the View (React component) and handle all actions on the canvas directly in the View and only store and update the canvas state or set the canvas element in the View and then register all canvas actions with a Store and use the View to dispatch Actions?

like image 403
Marco van Dijk Avatar asked Nov 10 '22 13:11

Marco van Dijk


1 Answers

Just send actions to store and listen for changes with canvas if there are updates - update canvas. Everything goes to action, action calls store it saves data and emits changes. Component listens for changes and updates it's state and view.

like image 170
Lukas Liesis Avatar answered Nov 14 '22 21:11

Lukas Liesis