<lambda>null1 package expo.modules.devlauncher.launcher
2 
3 import android.content.Intent
4 import kotlin.properties.Delegates
5 
6 typealias DevLauncherPendingIntentListener = (Intent) -> Unit
7 
8 interface DevLauncherIntentRegistryInterface {
9   var intent: Intent?
10 
11   fun subscribe(listener: DevLauncherPendingIntentListener)
12 
13   fun unsubscribe(listener: DevLauncherPendingIntentListener)
14 
15   fun consumePendingIntent(): Intent?
16 }
17 
18 class DevLauncherIntentRegistry : DevLauncherIntentRegistryInterface {
19   private val pendingIntentListeners = mutableListOf<DevLauncherPendingIntentListener>()
newValuenull20   override var intent by Delegates.observable<Intent?>(null) { _, _, newValue ->
21     newValue?.let { intent ->
22       pendingIntentListeners.forEach {
23         it.invoke(intent)
24       }
25     }
26   }
27 
subscribenull28   override fun subscribe(listener: DevLauncherPendingIntentListener) {
29     pendingIntentListeners.add(listener)
30   }
31 
unsubscribenull32   override fun unsubscribe(listener: DevLauncherPendingIntentListener) {
33     pendingIntentListeners.remove(listener)
34   }
35 
consumePendingIntentnull36   override fun consumePendingIntent(): Intent? {
37     val pendingIntent = intent
38     intent = null
39     return pendingIntent
40   }
41 }
42