diff --git a/grid.go b/grid.go index 63cdef5..ac9c4f2 100644 --- a/grid.go +++ b/grid.go @@ -370,6 +370,11 @@ func (t Tile[T]) Range(fn func(T) error) error { return nil } +// IsObserved returns whether the tile is observed or not +func (t Tile[T]) IsObserved() bool { + return t.data.IsObserved() +} + // Observers iterates over all views observing this tile func (t Tile[T]) Observers(fn func(view Observer[T])) { if !t.data.IsObserved() { diff --git a/view_test.go b/view_test.go index 08ffb25..2361788 100644 --- a/view_test.go +++ b/view_test.go @@ -52,7 +52,7 @@ func TestView(t *testing.T) { // Create a new view c := counter(0) - v := NewView[string, string](m, "view 1") + v := NewView(m, "view 1") v.Resize(NewRect(100, 0, 200, 100), c.count) assert.NotNil(t, v) assert.Equal(t, 10000, int(c)) @@ -338,7 +338,7 @@ func countObserversAt(m *Grid[string], x, y int16) (count int) { func countObservers(m *Grid[string]) int { var observers int m.Each(func(p Point, t Tile[string]) { - if t.data.IsObserved() { + if t.IsObserved() { observers++ } })