Skip to content

Latest commit

 

History

History
120 lines (81 loc) · 3.93 KB

EquinoxViewModel.md

File metadata and controls

120 lines (81 loc) · 3.93 KB

EquinoxViewModel

Usage/Examples

TestViewModel

class TestViewModel : EquinoxViewModel() {

    fun refreshRoutine() {
        execRefreshingRoutine(
            currentContext = Test::class.java,
            routine = {

                // your refresh routine

            }
        )
    }

}

Test class

class Test {

    @Composable
    fun Screen() {

        // instantiate the viewmodel
        val viewModel = TestViewModel()

        // set the current context where is a routine is executing
        viewModel.setActiveContext(this::class.java)

        // some state to control the visibility of an element on screen
        val show = remember { mutableStateOf(false) }

        // start the refreshing routine
        viewModel.refreshRoutine()

        // an example composable linked to 'show' state
        EquinoxAlertDialog(
            show = show,
            title = "Any title",
            text = "Any text",
            viewModel = viewModel, // passing the viewmodel allows the component to automatically suspend or restart the refresher
            onDismissAction = {

                // your code

                show.value = false // the refresh routine will be restated
            },
            dismissText = "Dismiss",
            confirmText = "Confimer",
            confirmAction = {

                // your code

                show.value = false // the refresh routine will be restated
            }
        )
        Button(
            onClick = {

                // your code

                show.value = true // the refresh routine will be suspended
            }
        ) {
            Text(
                text = "Show"
            )
        }
    }

}

The other apis will be gradually released

Support

If you need help using the library or encounter any problems or bugs, please contact us via the following links:

Thank you for your help!

Badges

Twitter

Donations

If you want support project and developer

Crypto Address Network
3H3jyCzcRmnxroHthuXh22GXXSmizin2yp Bitcoin
0x1b45bc41efeb3ed655b078f95086f25fc83345c4 Ethereum
AtPjUnxYFHw3a6Si9HinQtyPTqsdbfdKX3dJ1xiDjbrL Solana

If you want support project and developer with PayPal

Copyright © 2025 Tecknobit