@screeb/react-native 2.1.4 → 2.1.5

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.
@@ -28,7 +28,7 @@ class ScreebModuleModule(reactContext: ReactApplicationContext) :
28
28
  @ReactMethod
29
29
  fun initSdk(channelId: String, userId: String?, properties: ReadableMap?, hooks: ReadableMap?, initOptions: ReadableMap?) {
30
30
  Log.d("ScreebModule", "Called initSdk : $userId")
31
- Screeb.setSecondarySDK("react-native", "2.1.1")
31
+ Screeb.setSecondarySDK("react-native", "2.1.5")
32
32
  var map: HashMap<String, Any?>? = null
33
33
  if (properties != null) {
34
34
  map = properties.toHashMap()
@@ -11,7 +11,7 @@ class ScreebModule: RCTEventEmitter {
11
11
  properties properties_: [String: Any]?,
12
12
  hooks hooks_: [String: Any]?,
13
13
  initOptions initOptions_: [String: Any]?) {
14
- Screeb.setSecondarySDK(name: "react-native", version: "2.1.1")
14
+ Screeb.setSecondarySDK(name: "react-native", version: "2.1.5")
15
15
  var map: [String: AnyEncodable?] = [:]
16
16
  if (properties_ != nil) {
17
17
  map = self.mapToAnyEncodable(map: properties_!)
@@ -112,7 +112,19 @@ function handleEvent(event) {
112
112
  const originalHookId = parsedPayload?.hook_id;
113
113
  if (originalHookId) {
114
114
  // result must be a map to fit with react native allowed types
115
- ScreebModule.onHookResult(originalHookId, { result });
115
+ // Check if hook is a promise/async function
116
+ if (result instanceof Promise) {
117
+ result
118
+ .then((result) => {
119
+ ScreebModule.onHookResult(originalHookId, { result });
120
+ })
121
+ .catch((error) => {
122
+ console.error(error);
123
+ });
124
+ }
125
+ else {
126
+ ScreebModule.onHookResult(originalHookId, { result });
127
+ }
116
128
  }
117
129
  }
118
130
  }
@@ -96,7 +96,19 @@ function handleEvent(event) {
96
96
  const originalHookId = parsedPayload?.hook_id;
97
97
  if (originalHookId) {
98
98
  // result must be a map to fit with react native allowed types
99
- ScreebModule.onHookResult(originalHookId, { result });
99
+ // Check if hook is a promise/async function
100
+ if (result instanceof Promise) {
101
+ result
102
+ .then((result) => {
103
+ ScreebModule.onHookResult(originalHookId, { result });
104
+ })
105
+ .catch((error) => {
106
+ console.error(error);
107
+ });
108
+ }
109
+ else {
110
+ ScreebModule.onHookResult(originalHookId, { result });
111
+ }
100
112
  }
101
113
  }
102
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screeb/react-native",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Continuous Product Discovery",
5
5
  "scripts": {
6
6
  "clean": "rm -rf lib/",
package/src/index.tsx CHANGED
@@ -147,7 +147,18 @@ function handleEvent(event: any) {
147
147
  const originalHookId = parsedPayload?.hook_id;
148
148
  if (originalHookId) {
149
149
  // result must be a map to fit with react native allowed types
150
- ScreebModule.onHookResult(originalHookId, { result });
150
+ // Check if hook is a promise/async function
151
+ if (result instanceof Promise) {
152
+ result
153
+ .then((result) => {
154
+ ScreebModule.onHookResult(originalHookId, { result });
155
+ })
156
+ .catch((error) => {
157
+ console.error(error);
158
+ });
159
+ } else {
160
+ ScreebModule.onHookResult(originalHookId, { result });
161
+ }
151
162
  }
152
163
  }
153
164
  }