Some question about dependency injection. How would i go about injecting a function in to another one to decide whether this function should load sample data/test data or live data.
I heard about partial application. Is that the way to go? In C# one would use interface injection and this decides which interface and in the end which method call to where.
I was thinking, something like …
// this method should execute readdata and then this method knows whether to go to a json file or a rest service to get the data from (i guess these methods would be in other modules (e.g. module restjson, filejson)
…let getProjects (readData: string -> Project list option): Project list option = …
…let readFromFile = filejson.readProjects
…let readFromJson = restjson.readProjects
…let getSampleProjects = sdk.getProjects readFromFile ???
…let getLiveProject = sdk.getProjects readFromJson ???
Not sure if that in any way make sense. I am still learning. Please help me on the way.