-
Notifications
You must be signed in to change notification settings - Fork 46
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
Feature Request: De/Attachable Subgraphs #24
Comments
The following feels like it should work, but I get julia> using Reactive
julia> shader = Input(Input("first shader"))
"first shader"
julia> dummyInput = foldl(Input("initial value"), shader) do main, newSignal
lift((val) -> push!(main, val), newSignal)
end
"initial value"
julia> lift(dummyInput) do v
println(string("Value! ", v.value))
end
Value! initial value
nothing
julia> mySignal = Input("bar")
"bar"
julia> push!(shader, mySignal)
ERROR: push! called when another signal is still updating.
in push! at /Users/mullery1/.julia/v0.3/Reactive/src/Reactive.jl:257 A similar (but much more complicated) library for JavaScript called Bacon.js has a using Reactive
shader = Input(Input("first shader"))
dummyInput = flatten(shader)
lift(shader) do value
println(string("Got a value: ", value))
end
# now prints "Got a value: first shader"
myNewSignal = Input("second shader")
push!(shader, myNewSignal) # prints "Got a value: second shader"
push!(myNewSignal, "third shader") # prints "Got a value: third shader" A large part of the power of reactive programming is that you can have signals of signals (or streams of streams, or however you want to think about them). I'd love to see The only issue that I could see is that whenever you plug in a new signal, it will "hijack" the shader stream. For instance, say you had an initial shader stored in the |
Yeah initial values are a bit cumbersome, especially when you work with events, that not yet exist.
|
@SimonDanisch I think what you are looking for is to I still think the right way to do this is not have Reactive as a dependency at all in GLPlot. Maybe only for setting up input signals from the window. makeshader should just be the do block that is inside. function useshader( sourcecode)
#... Make new shader
#... Delete old shader
# also tell OpenGL to use the new shader
end And then the user could do: using Reactive
newsource = lift(useshader, lift(x -> readall(open("filename")), every(1.0))) if they want to update the shaders at all. If they don't want to, they need not even bother learning about Reactive. As for the plot object:
Should definitely be
And then all you need to take care of is rendering a signal of plots if at all that's what the user wants to render. They can use the input signals from the window to create a signal of plots to render. What Reactive implements is loosely first order FRP almost identical to Elm. This means the graph can only grow by adding child nodes but cannot change in connectivity. This recent talk explains the tradeoffs when using signals of signals or reconfigurable signal graphs. I quite like the convenience Reactive provides right now without being too complicated. @BaconScript Thanks for the examples. |
I need to think about the others, but one quick comment: |
After watching the video I think it is quite clear: Why do I still use the dicts of Signals?! |
@SimonDanisch I just PR'd an implementation of However, I am of the opinion that this must be used sparingly for simplicity. |
Now that we have flatten and even |
Hi,
I've been speaking about this with Shashi, but I think so far I haven't had good examples, so the conclusion was mostly, that I'm using react wrong.
I did some more thinking, and I came to the conclusion, that we really need some mechanisms, to connect different react graphs, as you can't always construct the whole graph.
Example:
In an API I want to offer, to make a shader out of some string signal. But at shader creation, I don't want to force the user to decide, from which string signal he wants to create the shader.
Another example:
I'm working on widgets for my plots.
The data for a plot in GLPlot looks a little like this:
Now, at the part where I initialize this datastructure, I don't even remotely know, if the person wants to change the value via a my glwidgets, via the commandline with push!(), or if someone builds, for example, some tk wrapper.
Best,
Simon
The text was updated successfully, but these errors were encountered: