Vladimir
01/26/2025, 8:53 AMuseCase
to have multiple methods that are called inside the invoke()
block and that serve the final purpose of the said use case?
For example, a use case responsible for rendering a template having a method to retrieve the template from a backend or assets and another method for filling it out with valuesVladimir
01/26/2025, 8:54 AMclass RenderTemplateUseCase @Inject constructor(
private val templateRepository: TemplateRepository
) {
suspend fun invoke(templateId: String, values: Map<String, Any>): String {
val template = retrieveTemplate(templateId)
return fillTemplate(template, values)
}
private suspend fun retrieveTemplate(id: String): String {
return templateRepository.getTemplate(id)
}
private fun fillTemplate(template: String, values: Map<String, Any>): String {
// Template filling logic
}
}
Bob Ironthighs
02/02/2025, 4:18 AM