Fork me on GitHub
#re-frame
<
2015-11-09
>
nowprovision04:11:20

lets say I have an button to delete an item, dispatches deleted-item event, handler makes an ajax call to server to delete item and then success handler removes it from the local @db, next I want to redirect back to the listing page so dispatch [:redirect :listing] however I may want to reuse this flow when deleting multiple items, it seems kinda of wrong to embed a redirect in the success handler, I had consider one time event listening but not sure how that would fit in

nowprovision04:11:53

I kind of thinking of instead of using dispatch in event-click of creating a higher-level concept embracing data>functions>macros :onclick #(operation [:remove-item (:id item)], [:does-not-exist (:id :items)] , [:redirect :list-all-page]. ), first arg is what I initially had as a dispatch op, second vector is something that gets converted to a predicate (register-predicate ? ), third arg is a final event to dispatch once the pred turns true, hmmm

roberto14:11:24

oh, what about having a flag in your global state that indicates the next page? Or something else that would let you know that you should redirect? And instead of triggering the dispatch inside the lambda, put that inside a function, and subscribe to the flag that will indicate what to do? Then when you get the response from the server, you modify that flag accordingly?