react-native-carrot-quest 0.3.0 → 0.4.0

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.
@@ -3,6 +3,7 @@ buildscript {
3
3
  kotlinVersion: "2.0.21",
4
4
  minSdkVersion: 24,
5
5
  compileSdkVersion: 36,
6
+ ndkVersion: "27.1.12297006",
6
7
  // Carrot publishes one artifact per region flavour: `commonRelease` for the
7
8
  // default servers, `usRelease` for the US ones. Override from your app's
8
9
  // android/build.gradle:
@@ -48,6 +49,7 @@ android {
48
49
  namespace "com.margelo.nitro.carrotquest"
49
50
 
50
51
  compileSdkVersion getExtOrDefault("compileSdkVersion")
52
+ ndkVersion getExtOrDefault("ndkVersion")
51
53
 
52
54
  defaultConfig {
53
55
  minSdkVersion getExtOrDefault("minSdkVersion")
@@ -29,8 +29,9 @@ import java.util.Locale
29
29
  * that *disagree* fail with [CarrotQuestConfigurationConflictException] rather
30
30
  * than silently keeping the first configuration.
31
31
  *
32
- * `Carrot.setup` performs I/O, so call this off the main thread; this object
33
- * does not spawn its own thread, leaving the scheduler choice to the caller.
32
+ * `Carrot.setup` performs I/O, so this object runs it on its own background
33
+ * thread. The call returns as soon as the Initializing state is published, so
34
+ * it is safe to call from the main thread or the JS thread.
34
35
  */
35
36
  object CarrotQuestSetup {
36
37
  private const val TAG = "CarrotQuest"
@@ -211,17 +212,21 @@ object CarrotQuestSetup {
211
212
 
212
213
  val applicationContext = context.applicationContext
213
214
 
214
- try {
215
- start(applicationContext, options) { error ->
216
- if (error == null) {
217
- settleSuccess(applicationContext, identity, options)
218
- } else {
219
- settleFailure(error)
215
+ // The Initializing state above is already published, so calls that arrive
216
+ // before this thread runs queue as readiness waiters instead of failing.
217
+ Thread({
218
+ try {
219
+ start(applicationContext, options) { error ->
220
+ if (error == null) {
221
+ settleSuccess(applicationContext, identity, options)
222
+ } else {
223
+ settleFailure(error)
224
+ }
220
225
  }
226
+ } catch (error: Throwable) {
227
+ settleFailure(error)
221
228
  }
222
- } catch (error: Throwable) {
223
- settleFailure(error)
224
- }
229
+ }, "carrot-sdk-init").start()
225
230
  }
226
231
 
227
232
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-carrot-quest",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Unofficial React Native bindings for the Carrot quest SDK, built with Nitro Modules.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",