GithubHelp home page GithubHelp logo

Comments (5)

deividas717 avatar deividas717 commented on June 16, 2024

You don't need to pass viewModel manually. It should be injected by hilt. Pass only visisDetails parameter.

from compose-destinations.

waheed006 avatar waheed006 commented on June 16, 2024

Suppose in HomeViewModel I have data of user and I am moving from HomeScreen to Profile Screen and loading same HomeViewModel in ProfileScreen using hilt then there is no data of user. Like that HomeViewModel loads at new object with empty data. How to resolve this issue?

from compose-destinations.

deividas717 avatar deividas717 commented on June 16, 2024

You can pass user reference as an argument to AppointmentScreenDestionation

@Destination
@Composable
fun AppointmentScreen(
    navigator: DestinationsNavigator,
    visitDetail: VisitResponse,
    user: User
) {
 // rest of the logic 
}

Or better retrieve user info from database or preferences.

from compose-destinations.

waheed006 avatar waheed006 commented on June 16, 2024

So it means there is no way to pass viewmodel with full data from one Composable screen to another just like we did in Fragments in older way?

from compose-destinations.

raamcosta avatar raamcosta commented on June 16, 2024

ViewModels cannot be navigation arguments, this wasn’t different with Fragments.
If you want, you can share a ViewModel by getting it on the second screen, if you know what that ViewModel is tied to (Maybe the previous back stack entry, or a nav graph back stack entry, or the activity).

Check this:
https://composedestinations.rafaelcosta.xyz/common-use-cases/providing-viewmodels#share-viewmodels-between-multiple-destinations

from compose-destinations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.