Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better show and a bit better compile times #92

Merged
merged 10 commits into from
Nov 4, 2022
Merged

Conversation

SimonDanisch
Copy link
Member

No description provided.

@SimonDanisch
Copy link
Member Author

SimonDanisch commented Nov 4, 2022

  • uses functors for map/on/onany, which makes it easier to spot them in listeners and also seems to help a little bit with compilation latency
  • adds clear(obs), which disconnects the observable from any registered interactions as well as we can (TODO, can we do better?)
  • 3x faster register_callback and therefore on & friends
  • improves show:
    master:
julia> Observable(1)
Observable{Int64} with 0 listeners. Value:
1
julia> Observable{Any}(1)
Observable{Any} with 0 listeners. Value:
1
julia>  Observable{Any}()
Observable{Any} with 0 listeners. Value:
not assigned yet!
julia>  Observable{Any}(rand(1000))
Observable{Any} with 0 listeners. Value:
[0.8841847173085652, 0.17636229645481794, 0.1801141027029346, 0.8961865801112214, 0.9791553016060836, 0.09382024705822112, 0.5077761382502093, 0.7255823373854912, 0.43347224323187217, 0.13924684951959843    0.21019368689710627, 0.6806054284776022, 0.29723246950088134, 0.8230816367425313, 0.5785352956703508, 0.7225239242011102, 0.19871050884594854, 0.8674662591747743, 0.09680341443523366, 0.9864939526294473]
julia>  x = Observable(1); on(identity, x); x
Observable{Int64} with 1 listeners. Value:
1
julia> [Observable([1,2,3]) for i in 1:10]
10-element Vector{Observable{Vector{Int64}}}:
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]
 Observable{Vector{Int64}} with 0 listeners. Value:
[1, 2, 3]

With this PR:

julia> Observable(1)
Observable(1)
julia> Observable{Any}(1)
Observable{Any}(1)
julia> Observable{Any}()
Observable{Any}(#undef)
julia> Observable{Any}(rand(1000))
Observable{Any}([0.8127470313464235, 0.735393878810991, 0.7095205370330129, 0.6043941038142925, 0.41500734502339887, 0.15371862494000232, 0.332946579126833, 0.23599271044932846, 0.18083317456374992, 0.46464445715753    0.13030068962485086, 0.3153281177326117, 0.08606749675082415, 0.45109560134589866, 0.10314979098549393, 0.4062614517373486, 0.8990326462007261, 0.09229643099020479, 0.43403034011145425, 0.1689857869888235])
julia> x = Observable(1); on(identity, x); x
Observable(1)
    0 => identity(x) in Base at operators.jl:526
julia> [Observable([1,2,3]) for i in 1:10]
10-element Vector{Observable{Vector{Int64}}}:
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])
 Observable([1, 2, 3])

@SimonDanisch SimonDanisch merged commit bb1f9d7 into master Nov 4, 2022
@SimonDanisch SimonDanisch deleted the sd/better-show branch November 4, 2022 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant