From f9c6d17b2aa819ca612e57d333b1b9d415fa7b5a Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 15 Feb 2016 17:22:29 +0800 Subject: [PATCH] Reorder callbacks after append it --- callback.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/callback.go b/callback.go index 5c7b2417..d2f0cf04 100644 --- a/callback.go +++ b/callback.go @@ -94,8 +94,8 @@ func (cp *CallbackProcessor) Before(callbackName string) *CallbackProcessor { func (cp *CallbackProcessor) Register(callbackName string, callback func(scope *Scope)) { cp.name = callbackName cp.processor = &callback - cp.parent.reorder() cp.parent.processors = append(cp.parent.processors, cp) + cp.parent.reorder() } // 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()) cp.name = callbackName cp.remove = true - cp.parent.reorder() cp.parent.processors = append(cp.parent.processors, cp) + cp.parent.reorder() } // 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.processor = &callback cp.replace = true - cp.parent.reorder() cp.parent.processors = append(cp.parent.processors, cp) + cp.parent.reorder() } // Get registered callback