Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions grid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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++
}
})
Expand Down