Skip to content

Commit

Permalink
Merge pull request #24 from paug/create-only-one-firebaseapp
Browse files Browse the repository at this point in the history
Keep the FirebaseApp in cache
  • Loading branch information
martinbonnin authored Mar 26, 2024
2 parents eb07602 + bf049eb commit 0eaeae0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
java-version: 17
- name: Build with Gradle
run: |
./gradlew build -Dorg.gradle.jvmargs=-Xmx1g
./gradlew build
./gradlew publishIfNeeded
env: # Or as an environment variable
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.jvmargs=-Xmx4g

kotlin.daemon.jvmargs=-Xmx4g

#Kotlin
kotlin.code.style=official
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ data class OpenFeedbackFirebaseConfig(
}
}

fun OpenFeedbackFirebaseConfig.toFirebaseApp(): FirebaseApp = Firebase.initialize(
context = context,
options = dev.gitlive.firebase.FirebaseOptions(
projectId = projectId,
applicationId = applicationId,
apiKey = apiKey,
databaseUrl = databaseUrl
),
name = appName
)
private val appCache = mutableMapOf<OpenFeedbackFirebaseConfig, FirebaseApp>()

fun OpenFeedbackFirebaseConfig.toFirebaseApp(): FirebaseApp {
return appCache.getOrPut(this) {
Firebase.initialize(
context = context,
options = dev.gitlive.firebase.FirebaseOptions(
projectId = projectId,
applicationId = applicationId,
apiKey = apiKey,
databaseUrl = databaseUrl
),
name = appName
)
}
}
Binary file not shown.

0 comments on commit 0eaeae0

Please sign in to comment.