versacall-core-library-react 2.0.34 → 2.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,7 +55,7 @@ function (_Component) {
55
55
  _createClass(ChannelsConsumer, [{
56
56
  key: "componentDidMount",
57
57
  value: function componentDidMount() {
58
- this.props.channels.registerHandlers(this.props.id, this.props.handler, this.props.connectionChanged);
58
+ this.props.channels.registerHandlers(this.props.id, this.props.handler, this.props.connectionChanged, this.props.subscribing);
59
59
  }
60
60
  }, {
61
61
  key: "componentWillUnmount",
@@ -77,11 +77,13 @@ ChannelsConsumer.propTypes = {
77
77
  id: _propTypes.default.string.isRequired,
78
78
  handler: _propTypes.default.func.isRequired,
79
79
  connectionChanged: _propTypes.default.func,
80
+ subscribing: _propTypes.default.func,
80
81
  addDefaultChannels: _propTypes.default.bool,
81
82
  channels: _propTypes.default.objectOf(_propTypes.default.func).isRequired
82
83
  };
83
84
  ChannelsConsumer.defaultProps = {
84
85
  connectionChanged: null,
86
+ subscribing: null,
85
87
  addDefaultChannels: true,
86
88
  children: null
87
89
  };
@@ -44,6 +44,7 @@ var channelInformation = [];
44
44
  var channelFunctions = [];
45
45
  var handlers = [];
46
46
  var connectionChangedHandlers = [];
47
+ var subscribingHandlers = [];
47
48
  var client;
48
49
 
49
50
  function compareChannelInfo(ci1, ci2) {
@@ -70,7 +71,7 @@ function compareChannelInfo(ci1, ci2) {
70
71
  return true;
71
72
  }
72
73
 
73
- var _registerHandlers = function registerHandlers(id, handler, connectionChanged) {
74
+ var _registerHandlers = function registerHandlers(id, handler, connectionChanged, subscribing) {
74
75
  var existing = handlers.find(function (x) {
75
76
  return x.id === id;
76
77
  });
@@ -89,7 +90,7 @@ var _registerHandlers = function registerHandlers(id, handler, connectionChanged
89
90
  return x.id === id;
90
91
  });
91
92
 
92
- if (existing !== undefined) {
93
+ if (existingConnectionChanged !== undefined) {
93
94
  existingConnectionChanged.handler = connectionChanged;
94
95
  } else {
95
96
  connectionChangedHandlers.push({
@@ -98,6 +99,21 @@ var _registerHandlers = function registerHandlers(id, handler, connectionChanged
98
99
  });
99
100
  }
100
101
  }
102
+
103
+ if (subscribing) {
104
+ var existingSubscribing = subscribingHandlers.find(function (x) {
105
+ return x.id === id;
106
+ });
107
+
108
+ if (existingSubscribing !== undefined) {
109
+ existingSubscribing.handler = subscribing;
110
+ } else {
111
+ subscribingHandlers.push({
112
+ id: id,
113
+ handler: subscribing
114
+ });
115
+ }
116
+ }
101
117
  };
102
118
 
103
119
  var _unregisterHandlers = function unregisterHandlers(id) {
@@ -116,6 +132,14 @@ var _unregisterHandlers = function unregisterHandlers(id) {
116
132
  if (existingConnectionChanged !== undefined) {
117
133
  connectionChangedHandlers.splice(connectionChangedHandlers.indexOf(existingConnectionChanged), 1);
118
134
  }
135
+
136
+ var existingSubscribing = subscribingHandlers.find(function (x) {
137
+ return x.id === id;
138
+ });
139
+
140
+ if (existingSubscribing !== undefined) {
141
+ subscribingHandlers.splice(subscribingHandlers.indexOf(existingSubscribing), 1);
142
+ }
119
143
  };
120
144
 
121
145
  var _registerChannel = function registerChannel(id, _channelFunction) {
@@ -167,6 +191,12 @@ var notifyConnectionChanged = function notifyConnectionChanged(connected) {
167
191
  });
168
192
  };
169
193
 
194
+ var notifySubscribing = function notifySubscribing(channel) {
195
+ subscribingHandlers.forEach(function (x) {
196
+ x.handler(channel);
197
+ });
198
+ };
199
+
170
200
  var ChannelsProvider =
171
201
  /*#__PURE__*/
172
202
  function (_Component) {
@@ -303,17 +333,18 @@ function (_Component) {
303
333
  key: "subscribe",
304
334
  value: function subscribe(channelInfo) {
305
335
  var methodName = 'subscribe()';
306
- this.props.core.log('system', namespace, methodName, 'Subscribing', channelInfo);
336
+ this.props.core.log('system', namespace, methodName, "Subscribing to ".concat(channelInfo.channelName));
307
337
  client.subscribe({
308
338
  key: channelInfo.channelKey,
309
339
  channel: channelInfo.channelName
310
340
  });
341
+ notifySubscribing(channelInfo.channelName);
311
342
  }
312
343
  }, {
313
344
  key: "unsubscribe",
314
345
  value: function unsubscribe(channelInfo) {
315
346
  var methodName = 'unsubscribe()';
316
- this.props.core.log('system', namespace, methodName, 'Unsubscribing', channelInfo);
347
+ this.props.core.log('system', namespace, methodName, "Unsubscribing from ".concat(channelInfo.channelName));
317
348
  client.unsubscribe({
318
349
  key: channelInfo.channelKey,
319
350
  channel: channelInfo.channelName
@@ -344,8 +375,8 @@ function (_Component) {
344
375
  updateChannel: function updateChannel(id, data) {
345
376
  return _this5.updateChannel(id, data);
346
377
  },
347
- registerHandlers: function registerHandlers(id, handler, connectionChanged) {
348
- return _registerHandlers(id, handler, connectionChanged);
378
+ registerHandlers: function registerHandlers(id, handler, connectionChanged, subscribing) {
379
+ return _registerHandlers(id, handler, connectionChanged, subscribing);
349
380
  },
350
381
  registerChannel: function registerChannel(id, channelFunction) {
351
382
  return _registerChannel(id, channelFunction);
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "versacall": {
3
3
  "title": "Versacall Core Library React",
4
4
  "applicationType": "react-library",
5
- "build": 34
5
+ "build": 38
6
6
  },
7
7
  "name": "versacall-core-library-react",
8
- "version": "2.0.34",
8
+ "version": "2.0.38",
9
9
  "description": "Versacall Core Library",
10
10
  "main": "dist/index.js",
11
11
  "module": "dist/index.js",