Last active
July 18, 2022 15:24
-
-
Save chrsp/1ce93ca1a1b2e25dc9a9022627fca018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} | |
} |
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]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.