I am trying to come up with a design for an application I am working on.
Here is a basic picture of what I am looking to do. Everything up to the
Data Layer is totally fine but the
Data Layer makes request from the
Network Layer as shown in the picture, and that is one way, from
Data Layer to
Here is my dilemma. Some network requests need a token to be executed, but how do I get this token in the network layer if I cant access the
Data Layer from
The token gets generated by first logging in. So the user starts the login process from the
UI Layer ->
Login Service ->
Get User (from network layer). Then the token gets cached.
Process of a request that requires token
User executes a process that requires token from
UI Layer ->
XXX Service ->
Get XXX (from network layer); however, the
GET XXX request needs a
token (which was generated from the login process and now it exits in the
LoginInfoRepository) to make the request. How do I get access to that token?? I am confused, maybe I am doing something wrong in this design?
Note: I am trying to adhere to
single responsibility principle.
One way I thought to solve it is to pass the token from the repository to network layer in the constructor but again I am trying to adhere to
SRP and a single repository can only control itself it can’t access a different repository such as