Skip to content

jkrumbiegel/PullObservables.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PullObservables

Stable Dev Build Status Coverage

The problems with eager or push updating in Observables.jl are:

  • updating multiple observables in sequence fails if they're mapped together and are only valid after all are changed to their new state
  • every update traverses the whole computation graph it's connected to, potentially wasting a lot of resources if the result is not used

PullObservables solve these issues by only recomputing their values once requested (pulled). Here's an example:

using PullObservables

x = PullObservable([1, 2, 3])
y = PullObservable([4, 5, 6])
z = PullObservable{Vector{Int}}()
map!(z, x, y) do x, y
    println("Computing z")
    x .+ y
end
@show z[]

println("Updating x")
x[] = [1, 2, 3, 4]
println("Updating y")
y[] = [4, 5, 6, 7]
@show z[]
Computing z
z[] = [5, 7, 9]
Updating x
Updating y
Computing z
z[] = [5, 7, 9, 11]

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages