hotwired / turbo-android

Android framework for making Turbo native apps
MIT License
431 stars 49 forks source link

Allow a destination's contents to be refreshed #138

Closed jayohms closed 3 years ago

jayohms commented 3 years ago

To refresh a destination's contents, simply call refresh():

class WebFragment : TurboWebFragment() {

    // ...

    private fun respondToNativeFeature() {
        // Refresh the WebView contents
        refresh()

        // Or, refresh the contents without displaying progress
        refresh(displayProgress = false)
    }
}

To refresh the current destination from your Activity, use the delegate:

class MainActivity : AppCompatActivity(), TurboActivity {

    // ...

    private fun refreshAfterResumingApp() {
        delegate.currentNavDestination?.refresh()
    }
}

Addresses https://github.com/hotwired/turbo-android/issues/137