Skip to content

Commit 194fcfa

Browse files
committed
sendtables: Property.OnUpdate() - call handler with initial value
1 parent 53fda44 commit 194fcfa

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

sendtables/entity.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,10 @@ const (
314314
type PropertyUpdateHandler func(PropertyValue)
315315

316316
// OnUpdate registers a handler for updates of the Property's value.
317+
//
318+
// The handler will be called with the current value upon registration.
317319
func (pe *Property) OnUpdate(handler PropertyUpdateHandler) {
320+
handler(pe.value)
318321
pe.updateHandlers = append(pe.updateHandlers, handler)
319322
}
320323

sendtables/sendtables.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ func (sc *ServerClass) newEntity(entityDataReader *bit.BitReader, entityID int)
120120
h(entity)
121121
}
122122

123-
// Fire update-handlers
124-
for _, v := range entity.props {
125-
v.firePropertyUpdate()
126-
}
127-
128123
// Fire all post-creation actions
129124
for _, f := range entity.onCreateFinished {
130125
f()

0 commit comments

Comments
 (0)