-1
var readIndicatorNeedsDisplay: Driver<Bool> = .empty()
public func bindcellEvents(readNotificationID: String) {
        if let unreadNotificationIDs = UserDefaults.main?.unreadNotificationIDs, unreadNotificationIDs.contains(readNotificationID) {
            readIndicatorNeedsDisplay = true

        } else {
            UserDefaults.main?.unreadNotificationIDs.append(readNotificationID)
            readIndicatorNeedsDisplay = false

// Cannot assign value of type 'Bool' to type 'Driver<Bool>' (aka 'SharedSequence<DriverSharingStrategy, Bool>')

        }
    }

when i assign bool to driver Giving error: Cannot assign value of type 'Bool' to type 'Driver' (aka 'SharedSequence')

1 Answers1

0

You're not supposed to assign values directly to a Driver, and attempting to do so shows your fundamental misunderstanding of RxSwift. You should probably step back, and learn the basics, then come back to this problem.

However, if you want to feed values to a stream, you could use a PublishRelay:

var readIndicatorNeedsDisplay = PublishRelay<Bool>()

public func bindcellEvents(readNotificationID: String) {
    if let unreadNotificationIDs = UserDefaults.main?.unreadNotificationIDs, unreadNotificationIDs.contains(readNotificationID) {
        readIndicatorNeedsDisplay.accept(true)

    } else {
        UserDefaults.main?.unreadNotificationIDs.append(readNotificationID)
        readIndicatorNeedsDisplay.accept(false)
    }
}
Adis
  • 4,512
  • 2
  • 33
  • 40