I'm looking to see if i can genericize the following code a bit.
type recordType = [
| `Todo(todo, idFunction)
| `TodoItem(todoItem, idFunction)
let commitItemToSchema = (normalizedSchema, recordType) => {
switch(recordType){
| `Todo (todo, idFun) => {...normalizedSchema, todo: addOrModifyById(normalizedSchema.todo, todo, idFun)}
| `TodoItem(todoItem, idFun) => {...normalizedSchema, todoItem: addOrModifyById(normalizedSchema.todoItem, todoItem, idFun)}
};
};
Is there a way that I can get the \'Todo
or the 'TodoItem
from the variant as a variable?
Thanks