diff --git a/src/stipple/reactivity.jl b/src/stipple/reactivity.jl index 52274fb4..b4ce33be 100644 --- a/src/stipple/reactivity.jl +++ b/src/stipple/reactivity.jl @@ -121,6 +121,9 @@ end import Base.map! @inline Base.map!(f::F, r::Reactive, os...; update::Bool=true) where F = Base.map!(f::F, getfield(r, :o), os...; update=update) +Base.axes(r::Reactive, args...) = Base.axes(getfield(getfield(r, :o), :val), args...) +Base.lastindex(r::Reactive, args...) = Base.lastindex(getfield(getfield(r, :o), :val), args...) + const R = Reactive const PUBLIC = 1 const PRIVATE = 2 diff --git a/test/runtests.jl b/test/runtests.jl index 3612fb1c..a2c932b5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -380,6 +380,22 @@ end @test Stipple.json(jt2) == "json text 2" end +@testset "Indexing with `end`" begin + r = R([1, 2, 3]) + on(r) do r + r[end - 1] += 1 + end + @test r[end] == 3 + r[end] = 4 + @test r[end - 1] == 3 + @test r[end] == 4 + + df = DataFrame(:a => 1:3, :b => 12:14) + @test df[end, 1] == 3 + @test df[end, end] == 14 + @test df[:, end] == 12:14 +end + @testset "adding and removing stylesheets" begin function my_css() [style(""" @@ -399,4 +415,4 @@ end @test Stipple.Layout.THEMES[end] == my_css remove_css(my_css, byname = true) @test findfirst(==(my_css), Stipple.Layout.THEMES) === nothing -end +end \ No newline at end of file