title: How to share viewPager holder fragment viewModel?
body: <p>I use viewPager in a fragment, inside viewPager there are 4 fragment. In these fragments I want to use the parent fragment viewModel, but I don't know how to access to parent fragment.</p>
  <p>I don't want to use activityViewModels for init viewModel, beacause of lifecycle.</p>
  <p>I also use Hilt to inject staff.</p>
  <p>So I thouht that, I could pass parent fragment to ViewPagerAdapter, but I can't figure out how to access to this inside fragments?</p>
  <p>[Update]
  So I modified the pager adapter, and passed the parent fragment, after that, if I call this.parentFragment inside chield fragments, I get the same instance of parent fragment, but I still get a new instance of sharedViewModel</p>
  <pre><code>**ViewPagerAdapter**
  
  class ReservationMainViewPagerAdapter(
      fragmentManager: FragmentManager,
      lifecycle: Lifecycle,
      private val parentFragment: Fragment
  ) :
      FragmentStateAdapter(fragmentManager, lifecycle) {
      private var pageCount = 4
  
      override fun getItemCount(): Int {
          return pageCount
      }
  
      override fun createFragment(position: Int): Fragment {
          return when (position) {
              0 -&gt; DataSheetFragment()
              1 -&gt; ReservationFragment()
              2 -&gt; DocumentUploadFragment()
              3 -&gt; NoteFragment()
              else -&gt; throw Exception(&quot;invalid view&quot;)
          }
      }
  
      fun disableLastTwoPage() {
          pageCount = 2
          notifyDataSetChanged()
      }
  
      fun enableAllPage() {
          pageCount = 4
          notifyDataSetChanged()
      }
  }
  **Updated viewPager**
  class ReservationMainViewPagerAdapter(
      parentFragment: Fragment
  ) : FragmentStateAdapter(parentFragment) {
  
  
  **ViewPager init**
  adapter = ReservationMainViewPagerAdapter(childFragmentManager, lifecycle,this)
  
  **Parent fragment viewmodel init**
  
  @AndroidEntryPoint
  class DataSheetFragment : BaseBindingFragment&lt;FragmentDataSheetBinding,DataSheetViewModel&gt;() {
  
      private val viewModel: DataSheetViewModel by viewModels()
  
      private val reservationMainViewModel: ReservationMainViewModel by viewModels(
          ownerProducer = {this.parentFragment as Fragment}
      )
  
  
  </code></pre>