title: ReactiveCocoa: Handling Multiple Unbalanced Keyboard Notifications
body: <p>I am building a sample auth view controller with Reactive Cocoa. I know how to setup and receive notifications from the Keyboard in a reactive manner. However, I get unbalanced UP and DOWN notifications. Because of this, I have to setup a BOOL variable to see if if the keyboard has been previously raised but not dropped. Is there a way to do this Reactively? The complete project is <a href="https://github.com/rismay/AuthController/blob/master/AuthController/WSMAuthViewController.m" rel="nofollow">here</a>.</p>
  
  <pre><code>- (void)configureKeyboardAnimations {
  CGFloat duration = 0.9, damping = 0.8;
  @weakify(self);
  [[[NSNotificationCenter.defaultCenter rac_addObserverForName:UIKeyboardWillShowNotification
                                                        object:nil]
    takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification *notification) {
      @strongify(self);
      if (!self.tableViewOffset) {
          CGRect keyboardRect = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
          [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:damping
                initialSpringVelocity:0 options:UIViewAnimationOptionAllowAnimatedContent
                           animations:^{
                               self.tableView.frame = CGRectOffset(self.tableView.frame, 0,
                                                                   -CGRectGetHeight(keyboardRect));
                           } completion:^(BOOL finished) {}];
          self.tableViewOffset = YES; //I need this set immediately not at completion. 
      }
  }];
  
  [[[NSNotificationCenter.defaultCenter rac_addObserverForName:UIKeyboardWillHideNotification
                                                        object:nil]
    takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification *notification) {
      @strongify(self);
      CGRect keyboardRect = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
      [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:damping
            initialSpringVelocity:0 options:UIViewAnimationOptionAllowAnimatedContent
                       animations:^{
                           self.tableView.frame = CGRectOffset(self.tableView.frame, 0,
                                                               CGRectGetHeight(keyboardRect));
                       } completion:^(BOOL finished) {}];
      self.tableViewOffset = NO; //I need this set immediately not at completion. 
  }];
  </code></pre>
  
  <p>}</p>