Skip to content

Commit 0847111

Browse files
mapleafgoclaude
andcommitted
style(mobile): 简化 SetOnEvent 消除重复路径
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d24c7dc commit 0847111

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

mobile/api.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,12 @@ type EventListener interface {
184184
}
185185

186186
func (s *Singcast) SetOnEvent(l EventListener) {
187-
if l == nil {
188-
s.svc.SetOnEvent(nil)
189-
core.SetOnLogEvent(nil)
190-
} else {
191-
fn := func(eventType int32, json string) { l.OnEvent(eventType, json) }
192-
s.svc.SetOnEvent(fn)
193-
core.SetOnLogEvent(fn)
187+
var fn func(int32, string)
188+
if l != nil {
189+
fn = func(eventType int32, json string) { l.OnEvent(eventType, json) }
194190
}
191+
s.svc.SetOnEvent(fn)
192+
core.SetOnLogEvent(fn)
195193
}
196194

197195
// --- Memory ---

0 commit comments

Comments
 (0)