Skip to content

Commit 94df4b9

Browse files
committed
refactor: Split IBootstrapService to a new file and update comments
1 parent 1cb2953 commit 94df4b9

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.onesignal.core.internal.startup
2+
3+
import com.onesignal.OneSignal
4+
import com.onesignal.core.internal.application.IApplicationService
5+
import com.onesignal.core.internal.config.ConfigModel
6+
import com.onesignal.core.internal.config.ConfigModelStore
7+
8+
/**
9+
* Implement and provide this interface as part of service registration to indicate the service
10+
* wants to be instantiated and its [bootstrap] function called during the initialization process.
11+
*
12+
* When [IBootstrapService.bootstrap] is called, only [OneSignal.setAppId] have been called during
13+
* [OneSignal.initWithContext].
14+
*
15+
* This means the following is true:
16+
*
17+
* 1) An appContext is available in [IApplicationService.appContext].
18+
* 2) An appId is available in [ConfigModel.appId] via [ConfigModelStore.get]
19+
* 3) None of the [IStartableService.start] is called
20+
*
21+
* When bootstrap there is no guarantee that any other data is available. Typically a bootstrap service
22+
* must be instantiated immediately and will add their appropriate hooks to then respond to changes
23+
* in the system.
24+
*/
25+
interface IBootstrapService {
26+
/**
27+
* Called when the service is to be bootstrap. The appId and appContext have already been established.
28+
*/
29+
30+
fun bootstrap()
31+
}

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/startup/IStartableService.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ import com.onesignal.core.internal.config.ConfigModelStore
1515
* 1) An appContext is available in [IApplicationService.appContext].
1616
* 2) An appId is available in [ConfigModel.appId] via [ConfigModelStore.get]
1717
*
18-
* When started there is no guarantee that any other data is available. Typically a startable service
19-
* must be instantiated immediately and will add their appropriate hooks to then respond to changes
20-
* in the system.
18+
* When started there is no guarantee that any other data is available. Typically a startable service
19+
* can asynchronously start some lengthy process that doesn't require immediate use.
2120
*/
2221
interface IStartableService {
2322
/**
@@ -26,11 +25,3 @@ interface IStartableService {
2625
*/
2726
fun start()
2827
}
29-
30-
internal interface IBootstrapService {
31-
/**
32-
* Called when the service is to be started. The appId and appContext have already been
33-
* established.
34-
*/
35-
fun bootstrap()
36-
}

0 commit comments

Comments
 (0)