Gaëtan Renaudeau
7 years ago
5 changed files with 98 additions and 87 deletions
@ -0,0 +1,15 @@ |
|||
// @flow
|
|||
|
|||
// This is a test example for dev testing purpose.
|
|||
|
|||
import { Observable } from 'rxjs' |
|||
import { createCommand, Command } from 'helpers/ipc' |
|||
|
|||
const cmd: Command<void, string> = createCommand('ping', () => |
|||
Observable.create(o => { |
|||
o.next('pong') |
|||
o.complete() |
|||
}), |
|||
) |
|||
|
|||
export default cmd |
@ -1,45 +0,0 @@ |
|||
// @flow
|
|||
/* eslint-disable react/no-multi-comp */ |
|||
|
|||
import { Component, PureComponent } from 'react' |
|||
import { connect } from 'react-redux' |
|||
|
|||
import type { Node } from 'react' |
|||
import type { Device } from 'types/common' |
|||
|
|||
import { getCurrentDevice } from 'reducers/devices' |
|||
|
|||
type Props = { |
|||
device: Device, |
|||
children: (device: Device) => Node, |
|||
} |
|||
|
|||
let prevents = 0 |
|||
export class PreventDeviceChangeRecheck extends PureComponent<{}> { |
|||
componentDidMount() { |
|||
prevents++ |
|||
} |
|||
componentWillUnmount() { |
|||
prevents-- |
|||
} |
|||
render() { |
|||
return null |
|||
} |
|||
} |
|||
|
|||
class EnsureDevice extends Component<Props> { |
|||
shouldComponentUpdate(nextProps) { |
|||
if (prevents > 0) return false |
|||
return nextProps.device !== this.props.device |
|||
} |
|||
render() { |
|||
const { device, children } = this.props |
|||
return children(device) |
|||
} |
|||
} |
|||
|
|||
const mapStateToProps = state => ({ |
|||
device: getCurrentDevice(state), |
|||
}) |
|||
|
|||
export default connect(mapStateToProps)(EnsureDevice) |
Loading…
Reference in new issue