Closed togi closed 6 years ago
Agree, but In my experience most of the return cases from update function is "newState, Effect", hence to write all the time Next.next(model.copy(..), setOf(Effect)) or Next.next(model.copy(..), effects(Effect)) is tedious. Maybe implement another helper method in Next class?
That's true, the most common case is a single effect. The thing is, we've tried countless different variations of the next API and unfortunately most of the variants you can have become quite difficult to use in practice, as they cause type inference problems in Java. You can see some of the traces of this in the unit tests of mobius.
It's possible we could do better in some kotlin-specific helpers, so maybe there will be a mobius-kotlin library in the future. Either way I mostly wanted to let you know that right now we use next(newModel, effects(SomeEffect))
ourselves. It's a bit more verbose yes, but at the same time it reads quite easily.
I got your point - this is more ideomatic way of writing update function, will fix that.
Normally we would use
Effects.effects()
to do the same thing, for example: