I'm using Rxswift to design ViewModel. Below is the code that I wrote. In my first map operator used [weak self] and used guard to unwrap the value.
What I realized is 'self' that I unwrapped in first map is still available in second map and in all other operators below.
But I'm not quite sure why unwrapped self in first map operator is still available in operator below and whether there will be problems when using it in other operators
let textObservable = input.subject
.map { [weak self] _ -> [String] in
guard let self = self else { return [] }
return [$0]
}.map { maps in
maps.map { text -> String in
return self.makeString(string: text)
}
}