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

Provide onDispose callback in the LifecycleEffectOnce api #481

Open
Ibraheemxd opened this issue Sep 9, 2024 · 1 comment
Open

Provide onDispose callback in the LifecycleEffectOnce api #481

Ibraheemxd opened this issue Sep 9, 2024 · 1 comment

Comments

@Ibraheemxd
Copy link

It would be useful to have an onDispose callback in LifecycleEffectOnce. Also, the API should be similar to DisposableEffect, except it binds to the screen's lifecycle. Something like this:

LifecycleEffectOnce {
            val observer = LifecycleEventObserver { _, _->}
            lifecycle.addObserver(observer)

            onDispose {
                lifecycle.removeObserver(observer)
            }
        }

Currently, I've duplicated the LifecycleEffectStore logic for my use case, but it would be nice to have this feature in the library.

Originally posted by @shpasha in #425 (comment)

@s97712
Copy link

s97712 commented Sep 10, 2024

It would be great if child components could use it with CompositionLocal too.

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

2 participants