You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just from a slack discussion with @mschauer, which hopelessly nerd-sniped me, since I've always wanted static, no overhead observable graphs as well...
A possible implementation could be this:
struct StaticObservable{T, Listeners} <:Observables.AbstractObservable
listeners::Listeners
value::Base.RefValue{T}end
Base.getindex(obs::StaticObservable) = obs.value[]
Observables.listeners(obs::StaticObservable) = obs.listeners
_notify(val, funcs::Tuple{}) where F =nothingfunction_notify(val, funcs::Tuple)
f =first(funcs)
f(val)
_notify(val, Base.tail(funcs))
endfunction Base.notify(obs::StaticObservable)
val = observable[]
_notify(val, obs.listeners)
returnendfunction Base.setindex!(observable::StaticObservable, val)
observable.val[] = val
notify(observable)
return val
end
The question is how to construct the graph... Since the current API relies on lots of dynamic behavior, the normal API can't be used to construct the observables.
I had the idea to use static_obs = make_static(observables...), but the Observable api doesn't really allow to walk over the graph and convert the nodes to StaticObservable... So is the only way to use something like SoonToBeStaticObservable,
which works like Observable but keeps more information about the graph, and can then be converted via make_static to a static graph?
The text was updated successfully, but these errors were encountered:
Just from a slack discussion with @mschauer, which hopelessly nerd-sniped me, since I've always wanted static, no overhead observable graphs as well...
A possible implementation could be this:
The question is how to construct the graph... Since the current API relies on lots of dynamic behavior, the normal API can't be used to construct the observables.
I had the idea to use
static_obs = make_static(observables...)
, but the Observable api doesn't really allow to walk over the graph and convert the nodes toStaticObservable
... So is the only way to use something likeSoonToBeStaticObservable
,which works like
Observable
but keeps more information about the graph, and can then be converted viamake_static
to a static graph?The text was updated successfully, but these errors were encountered: