Skip to content

Commit

Permalink
remove mixin on Libraries/Components/ScrollResponder.js (facebook#21589)
Browse files Browse the repository at this point in the history
Summary:
Related to facebook#21485.
Removed Subscribable.Mixin from the Libraries/Components/ScrollResponder.js

 - [x] npm run prettier
 - [x] npm run flow-check-ios
 - [x] npm run flow-check-android

[GENERAL] [ENHANCEMENT] [Libraries/Components/ScrollResponder.js] - remove Subscribable.Mixin dependency
Pull Request resolved: facebook#21589

Differential Revision: D10275517

Pulled By: RSNara

fbshipit-source-id: 28af7f0944e978609a1b3be05b8a51557e67bc1b
  • Loading branch information
nissy-dev authored and facebook-github-bot committed Oct 10, 2018
1 parent f125291 commit 42db974
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const Dimensions = require('Dimensions');
const FrameRateLogger = require('FrameRateLogger');
const Keyboard = require('Keyboard');
const ReactNative = require('ReactNative');
const Subscribable = require('Subscribable');
const TextInputState = require('TextInputState');
const UIManager = require('UIManager');

Expand All @@ -25,6 +24,8 @@ const warning = require('fbjs/lib/warning');

const {ScrollViewManager} = require('NativeModules');

import type EmitterSubscription from 'EmitterSubscription';

/**
* Mixin that can be integrated in order to handle scrolling that plays well
* with `ResponderEventPlugin`. Integrate with your platform specific scroll
Expand Down Expand Up @@ -115,7 +116,10 @@ type State = {
type Event = Object;

const ScrollResponderMixin = {
mixins: [Subscribable.Mixin],
_subscriptionKeyboardWillShow: (null: ?EmitterSubscription),
_subscriptionKeyboardWillHide: (null: ?EmitterSubscription),
_subscriptionKeyboardDidShow: (null: ?EmitterSubscription),
_subscriptionKeyboardDidHide: (null: ?EmitterSubscription),
scrollResponderMixinGetInitialState: function(): State {
return {
isTouching: false,
Expand Down Expand Up @@ -602,28 +606,39 @@ const ScrollResponderMixin = {

this.keyboardWillOpenTo = null;
this.additionalScrollOffset = 0;
this.addListenerOn(
Keyboard,
this._subscriptionKeyboardWillShow = Keyboard.addListener(
'keyboardWillShow',
this.scrollResponderKeyboardWillShow,
);
this.addListenerOn(
Keyboard,
this._subscriptionKeyboardWillHide = Keyboard.addListener(
'keyboardWillHide',
this.scrollResponderKeyboardWillHide,
);
this.addListenerOn(
Keyboard,
this._subscriptionKeyboardDidShow = Keyboard.addListener(
'keyboardDidShow',
this.scrollResponderKeyboardDidShow,
);
this.addListenerOn(
Keyboard,
this._subscriptionKeyboardDidHide = Keyboard.addListener(
'keyboardDidHide',
this.scrollResponderKeyboardDidHide,
);
},

componentWillUnmount: function() {
if (this._subscriptionKeyboardWillShow != null) {
this._subscriptionKeyboardWillShow.remove();
}
if (this._subscriptionKeyboardWillHide != null) {
this._subscriptionKeyboardWillHide.remove();
}
if (this._subscriptionKeyboardDidShow != null) {
this._subscriptionKeyboardDidShow.remove();
}
if (this._subscriptionKeyboardDidHide != null) {
this._subscriptionKeyboardDidHide.remove();
}
},

/**
* Warning, this may be called several times for a single keyboard opening.
* It's best to store the information in this method and then take any action
Expand Down

0 comments on commit 42db974

Please sign in to comment.