title: How to make Dynamic sections with RxDataSource?
body: <p>An overview of what I am trying to achieve I am trying to make a notifications tableview and each notification is group by its created date, so the tableview sections will be the number of created date, each section with the notifications created at this date in the section title.
  I have searched a lot but didn't get an absolute answer how to make with RxDataSource
  the array is dynamic get loaded with dates received through an API?</p>
  <pre><code>class T : UITableViewDataSource {
      func numberOfSections(in tableView: UITableView) -&gt; Int {
          return array.count
      }
  }
  </code></pre>
  <p>All what I have found is to set the sections static like so</p>
  <pre><code>       ViewModel.AllNotificationsObservable
                  .map({ [NotificationSectionViewModel(header: &quot;Yet&quot;, items: $0.filter{$0.createAt.toDate()!.toString(format: &quot;yyyy-MM-dd&quot;) == Date().toString(format: &quot;yyyy-MM-dd&quot;) }),
                          NotificationSectionViewModel(header: &quot;Yesterday&quot;, items: $0)
                  ]
                  })
                  .bind(to: NotificationTableView.rx.items(dataSource: ViewModel.dataSource))
                  .disposed(by: notificationDisposeBag)
  
  </code></pre>
  <p>this is my struct</p>
  <pre><code>struct NotificationSectionViewModel {
      var header: String
      var items: [AllNotificationModel] 
  }
  extension NotificationSectionViewModel: SectionModelType {
      typealias NotificationItem = AllNotificationModel
      
      init(original: NotificationSectionViewModel, items: [AllNotificationModel]) {
          self = original
          self.items = items
      }
  }
  </code></pre>
  <p>and this the data model</p>
  <pre><code>class AllNotificationModel : Codable {
      
      let id, userID : Int
      let title, body, createAt: String
      
      enum CodingKeys: String, CodingKey {
          case id, title, body
          case userID = &quot;user_id&quot;
          case createAt = &quot;create at&quot;
      }
  }
  </code></pre>
  <p>what I am trying to achieve</p>
  <p><a href="https://i.stack.imgur.com/u7gtk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u7gtk.png" alt="enter image description here" /></a></p>
  <p>need header to be like this</p>
  <pre><code>“Today”: [
          {
              &quot;id&quot;: 2421,
              &quot;user_id&quot;: 39,
              &quot;title&quot;: &quot;todayNotification&quot;,
              &quot;body&quot;: &quot;test&quot;,
              &quot;create at&quot;: &quot;2021-02-26 17:33:44&quot;
          },
          {
              &quot;id&quot;: 2349,
              &quot;user_id&quot;: 39,
              &quot;title&quot;: &quot;check&quot;,
              &quot;body&quot;: &quot;test&quot;,
              &quot;create at&quot;: &quot;2021-02-26 09:36:05&quot;
          },
          {
              &quot;id&quot;: 2206,
              &quot;user_id&quot;: 39,
              &quot;title&quot;: &quot;New Deal&quot;,
              &quot;body&quot;: &quot;new Deal 2&quot;,
              &quot;create at&quot;: &quot;2021-02-26 13:43:16&quot;
          } ]
  “Yesterday”: [
          {
              &quot;id&quot;: 2134,
              &quot;user_id&quot;: 39,
              &quot;title&quot;: &quot;Closed Deal&quot;,
              &quot;body&quot;: “deal deal”,
              &quot;create at&quot;: &quot;2021-02-25 13:21:30&quot;
          } ]
  
  “2021-02-24”: [
          {
              &quot;id&quot;: 2134,
              &quot;user_id&quot;: 39,
              &quot;title&quot;: &quot;Closed Deal&quot;,
              &quot;body&quot;: “deal”,
              &quot;create at&quot;: &quot;2021-02-24 13:21:30&quot;
          },
          {
              &quot;id&quot;: 2063,
              &quot;user_id&quot;: 39,
              &quot;title&quot;: &quot;New Deal&quot;,
              &quot;body&quot;: &quot;new Deal&quot;,
              &quot;create at&quot;: &quot;2021-02-24 13:21:16&quot;
          }]
  </code></pre>