Trigger Alt Flux Action From Legacy Javascript Framework

- 1 answer

I was wondering if there is a way I can trigger an Alt flux dispatcher event from outside of a React view? We are planning on replacing our frontend in an incremental fashion. So for example the Trolley has been rewritten using React + Flux however the product modules are not done and still use our legacy javaScript.

So essentially on click of the add button how can I trigger the already written Add dispatcher code that ultimately triggers a call to the back end server and updates the trolley display?

I realise this not great practice and this is in effect a sticking plaster until this area of the site is rewritten. Unfortunately we simply can't do it all in one go due to the size of the task and the number of devs.



You just have to trigger the action exactly in the same way you would have done it with react. It is not bound to react. Just import your actions and call them in the add callback. Then your store emit the changed event which you will have to listen to in your legacy component and manually update it with changed data.

import MyActions from 'actions/MyActions';

onAdd() {