Instantly share code, notes, and snippets.

Embed
What would you like to do?
fun loadContent() = quantum.setState {
if (isLoading) {
return@setState this
}
myRepository.loadContent
.onSuccess {
setState {
this@quantum.copy(content = content, error = null)
}
}
.onError {
setState {
copy(error = error)
}
}
.execute()
copy(isLoading = true)
}
@LockeWatts

This comment has been minimized.

Show comment
Hide comment
@LockeWatts

LockeWatts Sep 18, 2018

fun loadContent() = quantum.setState {

if (isLoading) {
    return@setState this
}

myRepository.loadContent
    .onSuccess {
        setState {
            this@quantum.copy(content = content, error = null)
        }
    }
    .onError {
       setState {
          this@quantum.copy(error = error)
       }
    }
    .execute()
copy(isLoading = true)   

}

Owner

LockeWatts commented Sep 18, 2018

fun loadContent() = quantum.setState {

if (isLoading) {
    return@setState this
}

myRepository.loadContent
    .onSuccess {
        setState {
            this@quantum.copy(content = content, error = null)
        }
    }
    .onError {
       setState {
          this@quantum.copy(error = error)
       }
    }
    .execute()
copy(isLoading = true)   

}

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