All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amplitude.core.State.kt Maven / Gradle / Ivy

The newest version!
package com.amplitude.core

import com.amplitude.core.platform.ObservePlugin

class State {
    var userId: String? = null
        set(value: String?) {
            field = value
            plugins.forEach { plugin ->
                plugin.onUserIdChanged(value)
            }
        }

    var deviceId: String? = null
        set(value: String?) {
            field = value
            plugins.forEach { plugin ->
                plugin.onDeviceIdChanged(value)
            }
        }

    val plugins: MutableList = mutableListOf()

    fun add(plugin: ObservePlugin, amplitude: Amplitude) = synchronized(plugins) {
        plugin.setup(amplitude)
        plugins.add(plugin)
    }

    fun remove(plugin: ObservePlugin) = synchronized(plugins) {
        plugins.removeAll { it === plugin }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy