react-native-gizwits-sdk-v5 1.3.66 → 1.3.67

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.
@@ -63,10 +63,10 @@ dependencies {
63
63
 
64
64
  implementation "androidx.startup:startup-runtime:$startup_version"
65
65
 
66
- implementation("io.github.gizwits:sdk:1.0.51")
67
- implementation("io.github.gizwits:sdk-bluetooth:1.0.51")
68
- implementation("io.github.gizwits:sdk-lan:1.0.51")
69
- implementation("io.github.gizwits:sdk-mqtt:1.0.51")
66
+ implementation("io.github.gizwits:sdk:1.0.52")
67
+ implementation("io.github.gizwits:sdk-bluetooth:1.0.52")
68
+ implementation("io.github.gizwits:sdk-lan:1.0.52")
69
+ implementation("io.github.gizwits:sdk-mqtt:1.0.52")
70
70
 
71
71
  // implementation files('libs/sdk-release.aar', 'libs/sdk-bluetooth-release.aar', 'libs/sdk-lan-release.aar', 'libs/sdk-mqtt-release.aar')
72
72
 
@@ -23,6 +23,7 @@ import com.gizwits.smart.sdk.lan.subscribeLanDeviceList
23
23
  import com.gizwits.smart.sdk.mqtt.mqttCapacity
24
24
  import com.gizwits.smart.sdk.mqtt.queryBoundDevices
25
25
  import com.gizwits.smart.sdk.mqtt.subscribeBoundDeviceList
26
+ import com.gizwits.smart.sdk.mqtt.subscribeBindEvent
26
27
  import com.google.gson.annotations.SerializedName
27
28
  import kotlinx.coroutines.CoroutineScope
28
29
  import kotlinx.coroutines.Dispatchers
@@ -65,7 +66,8 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
65
66
  enum class EventName(val value: String) {
66
67
  DeviceDataListener("DeviceDataListener"),
67
68
  DeviceListListener("DeviceListListener"),
68
- DeviceStateListener("DeviceStateListener")
69
+ DeviceStateListener("DeviceStateListener"),
70
+ DeviceBindStateListener("DeviceBindStateListener"),
69
71
  }
70
72
 
71
73
  /** @hide */
@@ -82,6 +84,19 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
82
84
  transform(it.first, it.second, it.third)
83
85
  }
84
86
  }
87
+ /** @hide */
88
+ @OptIn(ExperimentalCoroutinesApi::class)
89
+ fun <T1, T2, R> combineLatest(
90
+ flow1: Flow<T1>,
91
+ flow2: Flow<T2>,
92
+ transform: suspend (a: T1, b: T2) -> R
93
+ ): Flow<R> {
94
+ return combine(flow1, flow2) { value1, value2 ->
95
+ Pair(value1, value2)
96
+ }.mapLatest {
97
+ transform(it.first, it.second)
98
+ }
99
+ }
85
100
 
86
101
  override fun getName() = "RNGizSDKManagerModule"
87
102
  private val deviceListState: Flow<List<GizDevice>> =
@@ -98,10 +113,10 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
98
113
  override fun initialize() {
99
114
  super.initialize()
100
115
  CoroutineScope(Dispatchers.IO).launch {
101
- GizSDKManager.subscribeBindEvent().collect { data ->
116
+ GizSDKManager.subscribeBindEvent().collect {
102
117
  val data = JSONObject()
103
- data.put("did", data.first)
104
- data.put("isBind", data.second)
118
+ data.put("did", it.first)
119
+ data.put("isBind", it.second)
105
120
  sendEvent(EventName.DeviceBindStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
106
121
  }
107
122
  }
@@ -116,9 +131,9 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
116
131
  // 被移除的设备携程会自动销毁
117
132
  scope.launch {
118
133
  combineLatest(
119
- dev.bleCapacity.subscribeStatus(),
120
- dev.bleCapacity.subscribeIsLogin(),
121
- ).debounce(500).collectLatest { status, isLogin ->
134
+ dev.bleCapacity.subscribeStatus().debounce(500),
135
+ dev.bleCapacity.subscribeIsLogin().debounce(500),
136
+ ) { status, isLogin ->
122
137
  val data = JSONObject()
123
138
  data.put("state", status.toInt())
124
139
  data.put("isLogin", isLogin)
@@ -147,9 +162,9 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
147
162
 
148
163
  scope.launch {
149
164
  combineLatest(
150
- dev.lanCapacity.subscribeStatus(),
151
- dev.lanCapacity.subscribeIsLogin(),
152
- ).debounce(500).collectLatest { status, isLogin ->
165
+ dev.lanCapacity.subscribeStatus().debounce(500),
166
+ dev.lanCapacity.subscribeIsLogin().debounce(500),
167
+ ) { status, isLogin ->
153
168
  val data = JSONObject()
154
169
  data.put("state", status.toInt())
155
170
  data.put("isLogin", isLogin)
@@ -178,9 +193,9 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
178
193
 
179
194
  scope.launch {
180
195
  combineLatest(
181
- dev.mqttCapacity.subscribeStatus(),
182
- dev.mqttCapacity.subscribeIsLogin(),
183
- ).debounce(500).collectLatest { status, isLogin ->
196
+ dev.mqttCapacity.subscribeStatus().debounce(500),
197
+ dev.mqttCapacity.subscribeIsLogin().debounce(500),
198
+ ) { status, isLogin ->
184
199
  val data = JSONObject()
185
200
  data.put("state", status.toInt())
186
201
  data.put("isLogin", isLogin)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gizwits-sdk-v5",
3
- "version": "1.3.66",
3
+ "version": "1.3.67",
4
4
  "description": "Gizwits",
5
5
  "homepage": "https://github.com/demchenkoalex/react-native-gizwits-sdk-v5#readme",
6
6
  "main": "lib/index.js",
@@ -19,6 +19,6 @@ Pod::Spec.new do |s|
19
19
 
20
20
  s.dependency 'React'
21
21
  s.dependency 'CryptoSwift', '~> 1.8.0'
22
- s.dependency 'GizwitsiOSSDK', '~> 1.2.0'
22
+ s.dependency 'GizwitsiOSSDK', '~> 1.2.1'
23
23
 
24
24
  end