title: How to give same instance of ViewModel to both the Parent and Child fragment
body: <p>There are two Fragments: ParentFragment and ChildFragment.
  <code>ChildFragment</code> has been added to a view of the <code>ParentFragment</code>.</p>
  
  <p>Now using <code>Dagger2</code> for Android has the <code>ParentFragmentModule</code> with a method:</p>
  
  <pre><code>@Provides
  fun provideViewModel(fragment: ParentFragment, myViewModelFactory: MyViewModelFactory): MyViewModel {
      return ViewModelProviders.of(fragment, myViewModelFactory).get(MyViewModelImpl::class.java)
  }
  </code></pre>
  
  <p>Where MyViewModelFactory, MyViewModel, MyViewModelImpl are simple ViewModel logic created in the app.</p>
  
  <p>And the ChildFragmentModule has the method:</p>
  
  <pre><code>@Provides
  fun provideViewModel(fragment: ChildFragment, myViewModelFactory: MyViewModelFactory): MyViewModel {
      return ViewModelProviders.of(fragment, myViewModelFactory).get(MyViewModelImpl::class.java)
  }
  </code></pre>
  
  <p>This obviously is creating two separate instances of the <code>ViewModel</code> as they receive two different fragment instances.</p>
  
  <p>How do we make it return the same instance so that the data can be shared between both the Parent and Child fragments?</p>
  
  <p>I have tried passing the <code>ParentFragment</code> instead of <code>ChildFragment</code> in the <code>ChildFragmentModule</code>, but that leads to Dagger dependancy injection error.</p>