opentok-react
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -86,2 +86,3 @@ 'use strict'; | ||
if (shouldUpdate('videoSource', undefined)) { | ||
this.destroyPublisher(); | ||
this.createPublisher(); | ||
@@ -94,6 +95,5 @@ return; | ||
if (!prevProps.session && this.props.session) { | ||
if (this.props.session !== prevProps.session) { | ||
this.destroyPublisher(prevProps.session); | ||
this.createPublisher(); | ||
} else if (prevProps.session && !this.props.session) { | ||
this.destroyPublisher(prevProps.session); | ||
} | ||
@@ -165,5 +165,4 @@ } | ||
this.destroyPublisher(); | ||
if (!this.props.session) { | ||
this.setState({ publisher: null, lastStreamId: '' }); | ||
return; | ||
@@ -170,0 +169,0 @@ } |
@@ -19,5 +19,5 @@ 'use strict'; | ||
var _createSession = require('./createSession'); | ||
var _createSession2 = require('./createSession'); | ||
var _createSession2 = _interopRequireDefault(_createSession); | ||
var _createSession3 = _interopRequireDefault(_createSession2); | ||
@@ -49,5 +49,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
value: function componentWillMount() { | ||
this.createSession(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate(prevProps) { | ||
if (prevProps.apiKey !== this.props.apiKey || prevProps.sessionId !== this.props.sessionId || prevProps.token !== this.props.token) { | ||
this.createSession(); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
this.destroySession(); | ||
} | ||
}, { | ||
key: 'createSession', | ||
value: function createSession() { | ||
var _this2 = this; | ||
this.sessionHelper = (0, _createSession2.default)({ | ||
this.destroySession(); | ||
this.sessionHelper = (0, _createSession3.default)({ | ||
apiKey: this.props.apiKey, | ||
@@ -72,8 +91,10 @@ sessionId: this.props.sessionId, | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (this.props.eventHandlers && _typeof(this.props.eventHandlers) === 'object') { | ||
this.sessionHelper.session.off(this.props.eventHandlers); | ||
key: 'destroySession', | ||
value: function destroySession() { | ||
if (this.sessionHelper) { | ||
if (this.props.eventHandlers && _typeof(this.props.eventHandlers) === 'object') { | ||
this.sessionHelper.session.off(this.props.eventHandlers); | ||
} | ||
this.sessionHelper.disconnect(); | ||
} | ||
this.sessionHelper.disconnect(); | ||
} | ||
@@ -80,0 +101,0 @@ }, { |
@@ -70,6 +70,5 @@ 'use strict'; | ||
if ((!prevProps.session || !prevProps.stream) && this.props.session && this.props.stream) { | ||
if (this.props.session !== prevProps.session || this.props.stream !== prevProps.stream) { | ||
this.destroySubscriber(prevProps.session); | ||
this.createSubscriber(); | ||
} else if (prevProps.session && prevProps.stream && (!this.props.session || !this.props.stream)) { | ||
this.destroySubscriber(prevProps.session); | ||
} | ||
@@ -92,5 +91,4 @@ } | ||
this.destroySubscriber(); | ||
if (!this.props.session || !this.props.stream) { | ||
this.setState({ subscriber: null }); | ||
return; | ||
@@ -97,0 +95,0 @@ } |
{ | ||
"name": "opentok-react", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "React components for OpenTok.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
206958
690