Skip to content

Commit

Permalink
Reorder callbacks after append it
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Feb 15, 2016
1 parent 226c00b commit f9c6d17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f9c6d17

Please sign in to comment.