Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SubscribableMixin] remove mixin on Libraries/Components/ScrollResponder.js #21589

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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