ReactiveCocoa / ReactiveViewModel

Model-View-ViewModel, using ReactiveCocoa
MIT License
1.96k stars 259 forks source link

View model observing itself #6

Closed kastiglione closed 11 years ago

kastiglione commented 11 years ago

In order to do validation, I'm creating an isValid signal property on the view model. The signal is created the usual way with -combineLatest:reduce: with the input signals being RACObserve(self, propertyNameX). It seems strange to be observing self, but it also seems to be a necessary approach. Is this the way to do it, or is there a better way?

EDIT: Related to #2.

jspahrsummers commented 11 years ago

We observe self all the time. I don't see any problem with it in theory or practice.

Why do you feel like it's strange?

kastiglione commented 11 years ago

Yeah, I figured it was just me. I say "strange" because I've always known observing as technique for external objects to employ. Observing self feels like speaking of oneself in the third person. It's not that I thought there would be problems. Thanks for confirming.

jspahrsummers commented 11 years ago

I think it's comparable to subscribing to a signal on self, since properties are signals under RAC.

kastiglione commented 11 years ago

That is a helpful perspective.