0

I have the following code to configure my collectionView:

viewModel?
    .observableExercises
    .bindTo(
        exercisesCollectionView
            .rx
            .items(cellIdentifier: "My identifier",
                   cellType: ExerciseCollectionViewCell.self)) {
                    index, exercise, cell in
                    cell.exercise = exercise
    }
    .addDisposableTo(disposeBag)

It all works fine at first, but later when my viewModel.observableExercises gets updated I would like to have the exercisesCollectionView reload its data. How should I do it?

  • 2
    It should reload by it self – Daniel Poulsen Jan 09 '17 at 13:09
  • Maybe the problem is how I create the `observableExercises`. As for now I have an array of exercises and I create the observable with the `just` operator. The problem is that it emits the array and then `complete`. Is there a better way to create the observable? – Emannuel Carvalho Jan 19 '17 at 22:09
  • Don't emit the complete. That is why it is not reloading – Daniel Poulsen Jan 19 '17 at 22:13
  • Thank you, Daniel! I changed the implementation of my viewModel to have a Variable<[String]> instead of an Observable<[String]>. So whenever I change the `observableExercises.value` the collectionView reloads perfectly. – Emannuel Carvalho Jan 21 '17 at 18:27

0 Answers0