Skip to content

Commit e4e3dd2

Browse files
committed
notify parent object when child state mutates
1 parent cf01024 commit e4e3dd2

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Sources/LiveKit/Core/Room.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public class Room: NSObject, ObservableObject, Loggable {
185185
}
186186
}
187187

188+
// Notify Room when state mutates
188189
Task.detached { @MainActor in
189190
self.objectWillChange.send()
190191
}

Sources/LiveKit/Participant/Participant.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,12 @@ public class Participant: NSObject, ObservableObject, Loggable {
151151
}
152152
}
153153

154-
// notify object change when any state updates
154+
// Notify when state mutates
155155
Task.detached { @MainActor in
156+
// Notify Participant
156157
self.objectWillChange.send()
158+
// Notify Room
159+
self.room.objectWillChange.send()
157160
}
158161
}
159162
}

Sources/LiveKit/TrackPublications/TrackPublication.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,17 @@ public class TrackPublication: NSObject, ObservableObject, TrackDelegate, Loggab
131131
}
132132
}
133133

134+
// Notify when state mutates
134135
Task.detached { @MainActor in
136+
// Notify TrackPublication
135137
self.objectWillChange.send()
138+
139+
if let participant = self.participant {
140+
// Notify Participant
141+
participant.objectWillChange.send()
142+
// Notify Room
143+
participant.room.objectWillChange.send()
144+
}
136145
}
137146
}
138147
}

0 commit comments

Comments
 (0)