Remove Coordinate update event
Summary: This idea did not pan out Reviewed By: lblasa Differential Revision: D42453231 fbshipit-source-id: 1feac79b8655f4249e84b64cdce9fded6e5f5718
This commit is contained in:
committed by
Facebook GitHub Bot
parent
412d10b280
commit
a6ab3f5649
@@ -38,17 +38,6 @@ data class SubtreeUpdateEvent(
|
||||
}
|
||||
}
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
data class CoordinateUpdateEvent(
|
||||
val observerType: String,
|
||||
val nodeId: Id,
|
||||
val coordinate: Coordinate
|
||||
) {
|
||||
companion object {
|
||||
const val name = "coordinateUpdate"
|
||||
}
|
||||
}
|
||||
|
||||
/** Separate optional performance statistics event */
|
||||
@kotlinx.serialization.Serializable
|
||||
data class PerfStatsEvent(
|
||||
|
||||
@@ -17,8 +17,6 @@ import com.facebook.flipper.plugins.uidebugger.common.BitmapPool
|
||||
import com.facebook.flipper.plugins.uidebugger.core.Context
|
||||
import com.facebook.flipper.plugins.uidebugger.descriptors.Id
|
||||
import com.facebook.flipper.plugins.uidebugger.descriptors.MetadataRegister
|
||||
import com.facebook.flipper.plugins.uidebugger.model.Coordinate
|
||||
import com.facebook.flipper.plugins.uidebugger.model.CoordinateUpdateEvent
|
||||
import com.facebook.flipper.plugins.uidebugger.model.MetadataUpdateEvent
|
||||
import com.facebook.flipper.plugins.uidebugger.model.Node
|
||||
import com.facebook.flipper.plugins.uidebugger.model.PerfStatsEvent
|
||||
@@ -32,9 +30,6 @@ import kotlinx.serialization.json.Json
|
||||
|
||||
sealed interface Update
|
||||
|
||||
data class CoordinateUpdate(val observerType: String, val nodeId: Id, val coordinate: Coordinate) :
|
||||
Update
|
||||
|
||||
data class SubtreeUpdate(
|
||||
val observerType: String,
|
||||
val rootId: Id,
|
||||
@@ -43,18 +38,18 @@ data class SubtreeUpdate(
|
||||
val traversalCompleteTime: Long,
|
||||
val snapshotComplete: Long,
|
||||
val snapshot: BitmapPool.ReusableBitmap?
|
||||
) : Update
|
||||
)
|
||||
|
||||
/** Holds the root observer and manages sending updates to desktop */
|
||||
class TreeObserverManager(val context: Context) {
|
||||
|
||||
private val rootObserver = ApplicationTreeObserver(context)
|
||||
private lateinit var updates: Channel<Update>
|
||||
private lateinit var updates: Channel<SubtreeUpdate>
|
||||
private var job: Job? = null
|
||||
private val workerScope = CoroutineScope(Dispatchers.IO)
|
||||
private val txId = AtomicInteger()
|
||||
|
||||
fun enqueueUpdate(update: Update) {
|
||||
fun enqueueUpdate(update: SubtreeUpdate) {
|
||||
updates.trySend(update)
|
||||
}
|
||||
|
||||
@@ -72,15 +67,8 @@ class TreeObserverManager(val context: Context) {
|
||||
workerScope.launch {
|
||||
while (isActive) {
|
||||
try {
|
||||
when (val update = updates.receive()) {
|
||||
is SubtreeUpdate -> sendSubtreeUpdate(update)
|
||||
is CoordinateUpdate -> {
|
||||
val event =
|
||||
CoordinateUpdateEvent(update.observerType, update.nodeId, update.coordinate)
|
||||
val serialized = Json.encodeToString(CoordinateUpdateEvent.serializer(), event)
|
||||
context.connectionRef.connection?.send(CoordinateUpdateEvent.name, serialized)
|
||||
}
|
||||
}
|
||||
val update = updates.receive()
|
||||
sendSubtreeUpdate(update)
|
||||
} catch (e: CancellationException) {} catch (e: java.lang.Exception) {
|
||||
Log.e(LogTag, "Unexpected Error in channel ", e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user