Reorder callbacks after append it

This commit is contained in:
Jinzhu 2016-02-15 17:22:29 +08:00
parent 226c00b4a8
commit f9c6d17b2a
1 changed files with 3 additions and 3 deletions

View File

@ -94,8 +94,8 @@ func (cp *CallbackProcessor) Before(callbackName string) *CallbackProcessor {
func (cp *CallbackProcessor) Register(callbackName string, callback func(scope *Scope)) { func (cp *CallbackProcessor) Register(callbackName string, callback func(scope *Scope)) {
cp.name = callbackName cp.name = callbackName
cp.processor = &callback cp.processor = &callback
cp.parent.reorder()
cp.parent.processors = append(cp.parent.processors, cp) cp.parent.processors = append(cp.parent.processors, cp)
cp.parent.reorder()
} }
// Remove a registered callback // Remove a registered callback
@ -104,8 +104,8 @@ func (cp *CallbackProcessor) Remove(callbackName string) {
fmt.Printf("[info] removing callback `%v` from %v\n", callbackName, fileWithLineNum()) fmt.Printf("[info] removing callback `%v` from %v\n", callbackName, fileWithLineNum())
cp.name = callbackName cp.name = callbackName
cp.remove = true cp.remove = true
cp.parent.reorder()
cp.parent.processors = append(cp.parent.processors, cp) cp.parent.processors = append(cp.parent.processors, cp)
cp.parent.reorder()
} }
// Replace a registered callback with new callback // Replace a registered callback with new callback
@ -118,8 +118,8 @@ func (cp *CallbackProcessor) Replace(callbackName string, callback func(scope *S
cp.name = callbackName cp.name = callbackName
cp.processor = &callback cp.processor = &callback
cp.replace = true cp.replace = true
cp.parent.reorder()
cp.parent.processors = append(cp.parent.processors, cp) cp.parent.processors = append(cp.parent.processors, cp)
cp.parent.reorder()
} }
// Get registered callback // Get registered callback