SyncSubscription observe token


#1

How do you add listener to your SyncSubscriptions? The code from the documentation doesn’t seem to work:

let results = realm.objects(Person.self).filter("age > 18")
let subscription = results.subscribe()
let subscriptionToken = subscription.observe(\.state) { state in
    switch state {
    case .creating:
        print("creating")
    case .pending:
        print("pending")
    case .complete:
        print("complete")
    case .invalidated:
        print("invalidated")
    case .error(let err):
        print("err")
}

This code does not execute any of those cases. Am i missing something? TIA