5

Say I have the following:

UITextField *textField = [[UITextField alloc] init];

and a model object:

JSModel *model = [[JSModel alloc] init];

The following will give me a two-way binding (perhaps there are disadvantages with this approach that I'm not seeing?):

RAC(model, text) = textField.rac_textSignal;
RAC(textField, text) = RACObserve(model, text);

How can [UITextField rac_newTextChannel] be used to achieve this two-way binding?

codeperson
  • 8,050
  • 5
  • 32
  • 51

1 Answers1

11

Something like:

RACChannelTerminal *textFieldTerminal = [self.textField rac_newTextChannel];
RACChannelTerminal *modelTerminal = RACChannelTo(self.model, text);
[modelTerminal subscribe:textFieldTerminal];
[[textFieldTerminal skip:1] subscribe:modelTerminal];
joshaber
  • 2,465
  • 20
  • 13