# Combine: flatMap not allowing to change object value

**URL:** <https://forums.kodeco.com/t/combine-flatmap-not-allowing-to-change-object-value/140958>\
**Category:** Combine: Asynchronous Programming with Swift\
**Created:** [May 26, 2021, 9:09pm UTC](https://forums.kodeco.com/t/combine-flatmap-not-allowing-to-change-object-value/140958 "2021-05-26T21:09:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit\_tlp](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ankit_tlp/32/102075_2.png) [@ankit\_tlp](https://forums.kodeco.com/u/ankit_tlp)\
**Post date:** [May 26, 2021, 9:09pm UTC](https://forums.kodeco.com/t/combine-flatmap-not-allowing-to-change-object-value/140958/1 "2021-05-26T21:09:49Z")

</div>

This is Combine publisher stream that i am creating to get input from text and making web api request. But the problem i am facing is changing the request object’s properties (any mutable property in request object).

Below given code works fine but if i hold the request object like `var requestWeather = WeatherRequest(query:city)` and then pass it to `context.requestExecutor.executeRequest(request: requestWeather)` compiler gives an error. Please help me understand how can in make change to request object before passing it to executeRequest.

```auto
    anyCancellable = NotificationCenter.default.publisher(for: UITextField.textDidChangeNotification, object: self.placeNameField).compactMap { notification in
                (notification.object as? UITextField)?.text?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
            }.debounce(for: .milliseconds(500), scheduler: RunLoop.main).flatMap { [self] city in
                return (context.requestExecutor.executeRequest(request: WeatherRequest(query: city)) ).catch { error in
                    Just(Place(id: 0, name: "", coordinate: Coordinate.init(lat: 0, lon: 0), weatherValues: Weather.init(temp: nil, humidity: nil, pressure: nil)))
                }.map({ $0})
            }.sink { object in
                print("Returned data - \(object)")
            }

```
