You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Update function, there are a couple of cases like this:
is PlayButtonClicked ->
onPlayButtonClicked(model.copy(musicLocation = event.musicLocation), event.context)
...
fun onPlayButtonClicked(model: MainModel, context: Context): Next<MainModel, MainEffect> = Next.next(model,
effects(AttemptToPlay(model.musicLocation, model.status, context)))
It's probably easier to read if all the business logic for handling the event is in a single place rather than two, like so:
is PlayButtonClicked ->
onPlayButtonClicked(model, event)
...
fun onPlayButtonClicked(model: MainModel, event: PlayButtonClicked): Next<MainModel, MainEffect> =
Next.next(model.copy(musicLocation = event.musicLocation),
effects(AttemptToPlay(event.musicLocation, model.status, event.context)))
Some Spotify teams consistently use functions with the signature onEventName(model, event) for all event updates, even if the actual update doesn't need any data from the model/event. I'm personally leaning towards inlining simple updates and only passing relevant information, so something like:
return when (event) {
is SomethingSimple -> Next.noChange()
is NeedsDataFromEventOnly -> onNDFO(event)
is NeedsModel -> onNeedsModel(model)
// ...
}
The text was updated successfully, but these errors were encountered:
In the Update function, there are a couple of cases like this:
It's probably easier to read if all the business logic for handling the event is in a single place rather than two, like so:
Some Spotify teams consistently use functions with the signature
onEventName(model, event)
for all event updates, even if the actual update doesn't need any data from the model/event. I'm personally leaning towards inlining simple updates and only passing relevant information, so something like:The text was updated successfully, but these errors were encountered: