react-native-mosquito-transport 0.0.16 → 0.0.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mosquito-transport",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "React native javascript sdk for mosquito-transport (https://github.com/deflexable/mosquito-transport)",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -98,9 +98,12 @@ export const cloneInstance = (v) => {
98
98
  return v;
99
99
  }
100
100
 
101
- export const listenReachableServer = (callback, projectUrl) => ServerReachableListener.listenTo(projectUrl, t => {
102
- if (typeof t === 'boolean') callback?.(t);
103
- }, true);
101
+ export const listenReachableServer = (callback, projectUrl) => {
102
+ let lastValue;
103
+ return ServerReachableListener.listenTo(projectUrl, t => {
104
+ if (typeof t === 'boolean' && t !== lastValue) callback?.(t);
105
+ }, true);
106
+ }
104
107
 
105
108
  export const prefixStoragePath = (path, prefix = 'file:///') => {
106
109
  if (!path) return path;
package/src/index.js CHANGED
@@ -60,7 +60,7 @@ class RNMT {
60
60
  lastUid = thisUid;
61
61
 
62
62
  if (lastSocketProcess) disconnectionGlich[lastSocketProcess] = true;
63
- socket.close();
63
+ if (socket) socket.close();
64
64
 
65
65
  const thisProcess = ++lastSocketProcess;
66
66
  socket = io(`${this.config.wsPrefix}://${projectUrl.split('://')[1]}`, {