Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is a difference from Resaca ? #15

Open
terrakok opened this issue Sep 23, 2024 · 2 comments
Open

What is a difference from Resaca ? #15

terrakok opened this issue Sep 23, 2024 · 2 comments

Comments

@terrakok
Copy link

https://github.com/sebaslogen/resaca

By the first sight it is the same

@8cAyqpVKio
Copy link

I've used both Resaca and Rin.
Both Resaca's rememberScoped and Rin's rememberRetained serve the same purpose.
A difference, with rememberRetained, you can manage data lifecycle using RetainedObserver, like this.

class RetainedObserverImpl(val repository: Repository) : RetainedObserver {
var mutableState: MutableState<String> = mutableStateOf("-1")
val coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob())
override fun onForgotten() {
coroutineScope.cancel()
}
override fun onRemembered() {
coroutineScope.launch {
repository
.flow()
.collect {
mutableState.value = it.toString()
}
}
}
}

val state = rememberRetained {
RetainedObserverImpl(repository)
}.mutableState.value

@takahirom
Copy link
Owner

I actually didn't know about Resaca. Very interesting.
@8cAyqpVKio
Thank you for providing the reason to use Rin. Your opinion is valuable. I would like to know if there are reasons to use Resaca as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants