-
-
Save chrsp/1ce93ca1a1b2e25dc9a9022627fca018 to your computer and use it in GitHub Desktop.
// Module: Data | |
import Domain | |
public struct KitchenLocalDataSource: KitchenLocalRepository { | |
public func getIngredients(_ recipe: Recipe) -> [Ingredient]? { | |
// do something to fetch the ingredients needed from some local store: UserDefaults, CoreData, Memory Cache, KeychainManager etc | |
} | |
} | |
public struct KitchenRemoteDataSource: KitchenRemoteRepository { | |
public func getIngredients(_ recipe: Recipe, completion: ([Ingredient]?) -> Void)) { | |
// do something to fetch the ingredients needed from some remote store, usually calling your NetworkManager here | |
} | |
} |
In Domain Layer we have, Struct KitchenUseCase, KitchenProtocols and SpaghettiCarbonara files. So, what should i import for the Domain?
May i know where to call the below function from
public func prepareRecipe(_ recipe: Recipe) { }
Can i please have your email id, so that. can send the code i wrote based on your explanation.
Hi @harshadeepak11 . The Domain would contain normally the Models (DTOs) and the use cases of your system. This import works to illustrate that the Recipe
and Ingredient
comes from a module from outside. You could also create a dependency injection container to avoid the import, normally that would be the preferred approach in a real-world scenario.
Thanks a lot for quick reply sir.
I am still a bit confused in Importing, It would be really helpful for me if you could please send me the finished project possibly.
Here I am - [email protected]
Hi @chrsp , May i know what is import Domain Here?