title: ViewPager with viewmodel and live data , all 6 tabs data is replaced by last tab data
body: <p>I am working on a <code>ViewPager</code> with 6 <code>tabs</code> where it has only one fragment <code>TimesListFragment</code></p>
  
  <p>Depending on the arguments passed to <code>TimesListFragment</code> it calls api eg; science , technology, travel etc</p>
  
  <p>I have followed Google's <code>GithubBrowserSample</code> for my app</p>
  
  <p>I have <code>TimesListFragment</code> -> <code>TimesViewModel</code> -> <code>TimesRepository</code></p>
  
  <p>There are 6 tabs , when I hit the api all the tabs show the same result which if of the last <code>argument</code></p>
  
  <p><strong>StoriesPagerAdapter.kt</strong></p>
  
  <pre><code>class StoriesPagerAdapter(fragmentManager: FragmentManager?)
      :FragmentStatePagerAdapter(fragmentManager){
      private val sections= arrayListOf("science","technology","business","world","movies","travel")
      override fun getItem(position: Int): Fragment {
          return TimesListFragment.newInstance(sections[position])
      }
      override fun getCount(): Int {
          return sections.size
      }
      override fun getPageTitle(position: Int): CharSequence? {
          return sections[position]
      }
  }
  </code></pre>
  
  <p><strong>issue : all tabs shows data of <code>travel</code> arguments</strong></p>
  
  <p><strong>TimesViewModel</strong></p>
  
  <pre><code>class TimesViewModel @Inject constructor(private val timesRepository: TimesRepository) :
          ViewModel() {
      lateinit var data: LiveData&lt;Resource&lt;TimesStoriesResponse&gt;&gt;
      fun fetchStories(section:String): LiveData&lt;Resource&lt;TimesStoriesResponse&gt;&gt; {
          data = timesRepository.loadStories(section)
          return data
      }
  }
  </code></pre>
  
  <p><strong>TimesRepository.kt</strong></p>
  
  <pre><code>class TimesRepository @Inject constructor(private val apiService: ApiService,
                                            private val timesDao: TimesDao,
                                            private val appExecutors: AppExecutors) {
  
      private val repoListRateLimit = RateLimiter&lt;String&gt;(10, TimeUnit.MINUTES)
  
      fun loadStories(section:String): LiveData&lt;Resource&lt;TimesStoriesResponse&gt;&gt; {
          return object : NetworkBoundResource&lt;TimesStoriesResponse, TimesStoriesResponse&gt;(appExecutors) {
              override fun saveCallResult(item: TimesStoriesResponse) {
                  timesDao.insert(item)
              }
  
              override fun shouldFetch(data: TimesStoriesResponse?): Boolean {
                  return data == null  || repoListRateLimit.shouldFetch(section)
              }
  
              override fun loadFromDb() = timesDao.load()
  
              override fun createCall() = apiService.getTopStories(section,ConfigConstant.TIMES_KEY)
  
              override fun onFetchFailed() {
                  repoListRateLimit.reset(section)
              }
          }.asLiveData()
      }
  </code></pre>
  
  <p><strong>ApiService.kt</strong></p>
  
  <pre><code>interface ApiService {
      @GET("svc/topstories/v2/{section}.json?")
      fun getTopStories(@Path ("section") section:String,@Query("api-key") apiKey:String)
              :LiveData&lt;ApiResponse&lt;TimesStoriesResponse&gt;&gt;
  }
  </code></pre>
  
  <p><strong>TimesListFragment.kt</strong></p>
  
  <pre><code>private fun initViewModel() {
  
          viewModel = ViewModelProviders.of(this, viewModelFactory).get(section,TimesViewModel::class.java)
  
      }
  
      private fun initData() {
          viewModel?.fetchStories(section)?.observe(this, Observer {
  
              when (it?.status) {
  
                  Status.LOADING -&gt; {
                      showLoading(true)
                      showError(false,null)
                  }
  
  
                  Status.SUCCESS -&gt; {
                      showLoading(false)
                      showError(false,null)
                      showSuccessData(it.data)
                  }
  
                  Status.ERROR -&gt; {
                      showLoading(false)
                      showError(true,it.message)
                  }
  
              }
          })
      }
  </code></pre>
  
  <p><strong>note : both methods are called in onViewCreated() of <code>TimesListFragmnet</code></strong></p>