Marc
10/28/2021, 11:11 AMMarc
10/28/2021, 11:12 AMJavier
10/28/2021, 11:12 AMJavier
10/28/2021, 11:13 AMMarc
10/28/2021, 11:17 AMMarc
10/28/2021, 11:18 AMRepository <- DataSource
(called Service in this gist)Marc
10/28/2021, 11:18 AMdefaul
handy implementations like a cache repository that provides a policy to retrieve data or providing some default services to store data (in this case a simple Map. The final purpose is being able to build up this in a lego-like wayraulraja
10/28/2021, 11:37 AMMarc
10/28/2021, 11:44 AMMarc
10/28/2021, 11:44 AM/**
* Mapping a put service require bidirectional mapping input -> output -> input
*/
fun <K, A, B> Service<Put<K, A>, A>.map(input: (B) -> A, output: (A) -> B): Service<Put<K, B>, B> =
Service { (arg, value) -> invoke(Put(arg, input(value))).map(output) }
Marc
10/28/2021, 11:45 AMPut
requires the type make sme imposible to do a regular mapping like othersMarc
10/28/2021, 11:45 AMService<Put<K, A>, A>
would return Service<Put<K, A>, B>
Marc
10/28/2021, 11:47 AMserviceA: Service<Put<String, EntityUser>, EntityUser>
//I'd like
service.map(entityToDomain) -> to be Service<Put<String, User>, User>
//but instead I have
Service<Put<String, EntityUser>, User> //that's inconsistent
Marc
10/28/2021, 11:49 AM