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

please add compose sample. #43

Open
yangwuan55 opened this issue Apr 1, 2024 · 5 comments
Open

please add compose sample. #43

yangwuan55 opened this issue Apr 1, 2024 · 5 comments

Comments

@yangwuan55
Copy link

Thanks.

@clauub
Copy link

clauub commented Apr 12, 2024

@yangwuan55 did you find any compose sample? I needed some too. But I've managed to figure out how to make it work on compose

@yangwuan55
Copy link
Author

yangwuan55 commented Apr 15, 2024

@yangwuan55 did you find any compose sample? I needed some too. But I've managed to figure out how to make it work on compose

You can do like this:


        val facotry = rememberLocationTrackerFactory(LocationTrackerAccuracy.Best)
        val locationTracker = facotry.createLocationTracker(getPermissionController())
        BindLocationTrackerEffect(locationTracker)

        val viewModel = getScreenModel<SomeViewModel>()
        LaunchedEffect(locationTracker) {
            viewModel.init(locationTracker)
        }


In viewmodel:

suspend fun init(locationTracker: LocationTracker) {
        this.locationTracker = locationTracker
        locationTracker.startTracking()
}

fun onCleared() {
       locationTracker.stopTracking()
}


@ishaangarg
Copy link

    val locationTracker = facotry.createLocationTracker(getPermissionController())

could be
val locationTracker = remember { facotry.createLocationTracker(getPermissionController()) }
to avoid recomps

@rahulhundekari
Copy link

@yangwuan55 what does this method contains?
getPermissionController()
How it will be collected from Android and iOS?

@yangwuan55
Copy link
Author

@yangwuan55 what does this method contains? getPermissionController() How it will be collected from Android and iOS?

see here https://github.com/icerockdev/moko-permissions

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

4 participants