I am working on a JS application using the Flux architecture. Among other things, the application displays a list of contacts and on each of them you can add or remove them from your contact book.
The application is doing optimistic UI updates, so in this case you can click on 'add' and see 'remove' right away while in the background we are doing the ajax request to add the contact.
However I do not know how to handle the case when someone clicks on 'remove' while we are still adding the contact. The 'remove' ajax request expects an ID that we do not have yet. It is also a requirement that I cannot grey out the 'remove' button while the request is running.
My ideal way I think would be to be able to dispatch actions that are dependent on other action. Is that a good idea, how can I implement that?... :/
Do you guys know how I should handle this case in a flux application architecture?