Skip to content

Commit

Permalink
- import debounce from lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesemashko committed Apr 10, 2016
1 parent 6d02f62 commit 82c72ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"redux-devtools": "^3.0.0"
},
"dependencies": {
"lodash.debounce": "^4.0.4",
"react-json-tree": "^0.6.5",
"react-pure-render": "^1.0.2",
"redux-devtools-themes": "^1.0.0"
Expand Down
11 changes: 2 additions & 9 deletions src/LogMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ActionCreators } from 'redux-devtools';
import { updateScrollTop } from './actions';
import reducer from './reducers';
import LogMonitorEntryList from './LogMonitorEntryList';
import debounce from 'lodash.debounce';

const { reset, rollback, commit, sweep, toggleAction } = ActionCreators;

Expand Down Expand Up @@ -39,14 +40,6 @@ const styles = {
}
};

const debounced = (func, wait) => {
let timeout;
return () => {
clearTimeout(timeout);
timeout = setTimeout(func, wait);
};
};

export default class LogMonitor extends Component {
static update = reducer;

Expand Down Expand Up @@ -80,7 +73,7 @@ export default class LogMonitor extends Component {

shouldComponentUpdate = shouldPureComponentUpdate;

updateScrollTop = debounced(() => {
updateScrollTop = debounce(() => {
const node = this.refs.container;
this.props.dispatch(updateScrollTop(node ? node.scrollTop : 0));
}, 500);
Expand Down

0 comments on commit 82c72ba

Please sign in to comment.