I have a react-redux
app and my team uses grpc-web. I'm wondering - what's the best way to design such system?
For now the plan is to create 3 abstraction levels:
API
module - promisified wrappers aroundgrpc-web
clientsRedux thunks
level - async action creators that deal with the APIReact components props
- will ask for only what component needs
So components
know nothing about grpc
, they mess with action creators, action creators know nothing about grpc
, they deal with an api
module, and only api
module uses with grpc-web
stubbs.
Reasons why I want to go this way:
- No grpc-specific code in action creators and components
- My Promise-based API instead of a callback-based API of grpc-web
My questions are:
- Is it a good idea to have an abstraction level between Redux and grpc-web? Or it's better to keep that stuff inside action creators logic?
- Is there a common design pattern I should think of? (I am thinking about "Adapter")
- Is it a good idea to promisify
grpc-web
API? If yes, is it a good idea to write a function and do it on the fly? - Can I say that my current plan is Adapter Pattern?
- If I want to use an Adapter Pattern, am I have to map every element of data collection to my interface? I now that my components and, maybe, action-creators, should now depend on
grpc-web
API because it's backend API and it may change
Aucun commentaire:
Enregistrer un commentaire