3 ms·
redux-transform is a general transformation middleware. You can use it to transform an API response. But more intriguingly you can use APIs to transform an act
by papapopper 9y ago
redux-transform is a general transformation middleware.
You can use it to transform an API response. But more intriguingly you can use APIs to transform an action.
- davnicwil 9y agoWhat's the advantage of using this over: 1) transforming actions directly inside action creators 2) transforming responses inside redux-thunk thunks or redux-promise-middleware promises Maybe I'm not getting it, but with the above methods I can already transform my actions and responses. I can also use async/await if I want to mix async and sync logic in a readable way. This just seems to layer an abstraction over that sort of thing, but for what benefit? Is this actually intended to be an alternative to redux-thunk or redux-promise-middleware, and not used in conjunction with them? Genuinely asking for information and not trying to be critical, sometimes it's hard to see use cases and benefits of new patterns when you first encounter them :-)
- papapopper 9y agoredux-transform: 1. lets you transform an arbitrary number of fields with an arbitrary number of transformations 2. runs the transformers for each field concurrently It is true that there are other opportunities to transform actions, but you would have to implement the logic to perform arbitrary transformations. You can use async/await to mix async and sync logic, but you will have to be careful about concurrency. With redux-transform, you can just focus on implementing transformers, and specifying which ones to perform. redux-transform is intended to complement other middleware. You can use it in conjunction with both redux-thunk and redux-promise.