0
// View controller call

viewModel.bindNotificationReadEvents(readNotificationID: readNotificationIDPublisher.asDriver(onErrorDriveWith: .empty()))
   viewModel.reloadDataSourceForNotificationReadEvent.drive(reloadDataSourceForNotificationReadEventBinder).disposed(by: rx.disposeBag)

// View model

var reloadDataSourceForNotificationReadEvent: Driver<[NotificationItem]> = .empty()
fileprivate let dataSourceRelay = BehaviorRelay<[NotificationItem]>(value: [])

    public func bindNotificationReadEvents(readNotificationID: Driver<String>) {
            readNotificationID.drive(onNext: { [weak self] notificationID in
                // read notification IDs on User Defaults
                UserDefaults.main?.unreadNotificationIDs.append(notificationID)
                // Update data source relay
                self?.reloadDataSourceForNotificationReadEvent = readNotificationID.withLatestFrom(self?.dataSourceRelay.asDriver() ?? .empty())
            }).disposed(by: rx.disposeBag)
        }

when this method is called from the viewcontroller in the viewmodel it just skips both the lines and nothing executes when i checked it while debugging neither is the userdefaults updated nor is data source relay can someone please help me out.

fphilipe
  • 9,739
  • 1
  • 40
  • 52
  • There's not enough information. Please post a _minimal_ and **compilable** code sample. – Daniel T. Dec 27 '19 at 15:28
  • 1
    Don't ever make a Driver, Observable or Subject/Relay a `var`. Reseating one is an error. I can't show you the correct code without more information, but I can see that this is incorrect code. Provide a compilable example and I'll be able to show you how to make it correct. – Daniel T. Dec 28 '19 at 04:00

0 Answers0