Skip to content

What about Activity Configuration change handling? #14

Description

@bornest

First of all, thank you so much for such elaborate examples
and the amount of effort you're putting into bringing FP to Kotlin!

I've noticed that in all 4 examples
Activity just passes a reference to itself to the other part of the app
( e.g. by calling getSuperHeroes().run(heroesContext) in onResume() ),
so when the data is fetched from the server,
it is displayed by calling drawHeroes() method directly on that Activity reference:

private fun drawHeroes(view: SuperHeroesListView, success: List<CharacterDto>) {
  view.drawHeroes(success.map {
    SuperHeroViewModel(
        it.id,
        it.name,
        it.thumbnail.getImageUrl(PORTRAIT_UNCANNY),
        it.description)
  })
}

But what if this Activity is currently undergoing a Configuration change?
(it can be destroyed and not yet initialized again)
I assume in that case it may result in NPE or some other exception.

How do you actually handle this situation in such architecture?

P.S. I haven't been able to really check this, but I'm pretty sure that's how it is.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions