Only run events when the document has changed
This commit is contained in:
parent
e8accd1b8e
commit
4d155c61ce
2 changed files with 9 additions and 1 deletions
|
@ -601,7 +601,7 @@ func TestDefine(t *testing.T) {
|
||||||
So(res[6].Result, ShouldHaveLength, 1)
|
So(res[6].Result, ShouldHaveLength, 1)
|
||||||
So(res[7].Result, ShouldHaveLength, 1)
|
So(res[7].Result, ShouldHaveLength, 1)
|
||||||
So(res[8].Result, ShouldHaveLength, 1)
|
So(res[8].Result, ShouldHaveLength, 1)
|
||||||
So(res[9].Result, ShouldHaveLength, 4)
|
So(res[9].Result, ShouldHaveLength, 3)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,14 @@ import (
|
||||||
// table, and executes them in name order.
|
// table, and executes them in name order.
|
||||||
func (d *document) event(ctx context.Context, met method) (err error) {
|
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
|
// Get the event values specified
|
||||||
// for this table, loop through
|
// for this table, loop through
|
||||||
// them, and compute the events.
|
// them, and compute the events.
|
||||||
|
|
Loading…
Reference in a new issue