Only run events when the document has changed

This commit is contained in:
Tobie Morgan Hitchcock 2018-04-19 13:33:04 +01:00
parent e8accd1b8e
commit 4d155c61ce
2 changed files with 9 additions and 1 deletions

View file

@ -601,7 +601,7 @@ func TestDefine(t *testing.T) {
So(res[6].Result, ShouldHaveLength, 1)
So(res[7].Result, ShouldHaveLength, 1)
So(res[8].Result, ShouldHaveLength, 1)
So(res[9].Result, ShouldHaveLength, 4)
So(res[9].Result, ShouldHaveLength, 3)
})

View file

@ -25,6 +25,14 @@ import (
// table, and executes them in name order.
func (d *document) event(ctx context.Context, met method) (err error) {
// If this document has not changed
// then there is no need to perform
// any registered events.
if ok := d.changed(); !ok {
return
}
// Get the event values specified
// for this table, loop through
// them, and compute the events.