Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions Sources/MapConductorForMapKit/marker/MapKitMarkerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,19 @@ final class MapKitMarkerController: AbstractMarkerController<MKPointAnnotation,

private func subscribeToMarker(_ state: MarkerState) {
guard markerSubscriptions[state.id] == nil else { return }
markerSubscriptions[state.id] = state.asFlow()
.dropFirst() // Skip initial value to avoid triggering update on subscription
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
markerSubscriptions[state.id] = state.onChange { [weak self] in
guard let self else { return }
guard self.markerStatesById[state.id] != nil else { return }
MCLog.marker("MapKitMarkerController.onChange id=\(state.id) anim=\(String(describing: state.getAnimation()))")
// Update InfoBubble immediately using the latest MarkerState values.
// Renderer updates can be throttled/deferred, which otherwise makes the bubble lag behind rapid updates.
self.onUpdateInfoBubble(state.id)
Task { [weak self] in
guard let self else { return }
guard self.markerStatesById[state.id] != nil else { return }
MCLog.marker("MapKitMarkerController.asFlow emit id=\(state.id) anim=\(String(describing: state.getAnimation()))")
// Update InfoBubble immediately using the latest MarkerState values.
// Renderer updates can be throttled/deferred, which otherwise makes the bubble lag behind rapid updates.
await self.update(state: state)
self.onUpdateInfoBubble(state.id)
Task { [weak self] in
guard let self else { return }
await self.update(state: state)
self.onUpdateInfoBubble(state.id)
}
}
}
}

func getMarkerState(for id: String) -> MarkerState? {
Expand Down
Loading