How to filter array of Observable element | RxSwift

Try this:

let seq = Observable.just(personArray)


seq.just(personArray)
   .map{
       $0.filter{ $0.name.hasPrefix("M")}
   }
   .subscribe(onNext: { item in
       print(item)
   })

You also could do this:

let seq = Observable.just(personArray.filter{ $0.name.hasPrefix("M") })

Here is a simple playground example that I used to prototype the same problem:

import RxSwift

let dataSource = Observable.just([1, 2, 3, 4, 5])
let filterSource = PublishSubject<Int>()

Observable
    .combineLatest(dataSource, filterSource) { data, filter in data.filter { $0 != filter } }
    .subscribe(onNext: { print($0) })

filterSource.onNext(3)
filterSource.onNext(2)

print("Done")

This prints:

[1, 2, 4, 5]
[1, 3, 4, 5]
Done