Comments (7)
animate
already keeps a frame for you, so I wonder if the issue is being caused by rendering the same frame twice. Try this instead:
button = Kino.Control.button("Click") |> Kino.render()
items = [[a: "a", b: "b"], [a: "c",b: "d"]]
Kino.animate(button, 0, fn _event, counter ->
new_counter = counter + 1
current = Enum.at(items, counter)
inputs = [
example_a: Kino.Input.text("Example a: ", default: "#{current[:a]}"),
example_b: Kino.Input.text("Example b: ", default: "#{current[:b]}")
]
form = Kino.Control.form(inputs, submit: "Send")
{:cont, form, new_counter}
end)
from kino.
animate
already keeps a frame for you, so I wonder if the issue is being caused by rendering the same frame twice. Try this instead:button = Kino.Control.button("Click") |> Kino.render() items = [[a: "a", b: "b"], [a: "c",b: "d"]] Kino.animate(button, 0, fn _event, counter -> new_counter = counter + 1 current = Enum.at(items, counter) inputs = [ example_a: Kino.Input.text("Example a: ", default: "#{current[:a]}"), example_b: Kino.Input.text("Example b: ", default: "#{current[:b]}") ] form = Kino.Control.form(inputs, submit: "Send") {:cont, form, new_counter} end)
Still have the same issue with this code
Edit: Just to confirm it's not an issue with my browser, I switched from Firefox to Chrome, but still run into the same problem.
from kino.
I think there is a race condition happening in
Lines 172 to 177 in f961f8d
When putting an inspect after output
def handle_call({:render, term, destination}, _from, state) do
output = Kino.Render.to_livebook(term) |> IO.inspect()
put_update(destination, state.ref, [output], :replace)
state = update_outputs(state, destination, fn _ -> [output] end)
{:reply, :ok, state}
end
it magically works :-D
Couldn't figure out the details yet.
Here is a simple way to reproduce the error:
frame = Kino.Frame.new()
Kino.Frame.render(frame, Kino.Input.text("Test"))
from kino.
button = Kino.Control.button("Click") |> Kino.render()
items = [[a: "a", b: "b"], [a: "c",b: "d"]]
Kino.animate(button, 0, fn _event, counter ->
new_counter = counter + 1
current = Enum.at(items, counter)
inputs = [
example_a: Kino.Input.text("Example a: ", default: "#{current[:a]}"),
example_b: Kino.Input.text("Example b: ", default: "#{current[:b]}")
]
form = Kino.Control.form(inputs, submit: "Send")
{:cont, form, new_counter}
end)
In the latest Livebook nightly build, this example doesn't even work - the whole session crashes 😅
from kino.
I think there is a race condition happening in
Lines 172 to 177 in f961f8d
When putting an inspect after output
def handle_call({:render, term, destination}, _from, state) do output = Kino.Render.to_livebook(term) |> IO.inspect() put_update(destination, state.ref, [output], :replace) state = update_outputs(state, destination, fn _ -> [output] end) {:reply, :ok, state} endit magically works :-D Couldn't figure out the details yet.
Here is a simple way to reproduce the error:
frame = Kino.Frame.new()Kino.Frame.render(frame, Kino.Input.text("Test"))
I can't replicate my issue with this code - this seems to render correctly. I checked out the .10 branch of both Livebook and Kino and changed it to output = Kino.Render.to_livebook(term) |> IO.inspect()
but that doesn't seem to resolve the issue with Kino.animate
from kino.
@clayscode I pushed a fix to livebook main. Not sure if its the correct way to tackle the issue, but it works on my side.
Lets see what @jonatanklosko thinks :)
from kino.
@jannikbecher your PR seems to fix my issue, awesome!
from kino.
Related Issues (20)
- Postgre columns of type array can crash SQL smart cells.
- Support `:list` in Kino Table
- Feature request: Multi-select HOT 2
- Refactoring DataTable assets
- Allow Kino.DataTable to be updated
- Rerender an input will make it losing focus HOT 1
- Expand tuples in Kino.Tree by default HOT 7
- Update to Glide Data Grid v6
- Reevaluating a cell containing Kino.start_child! sometimes errors with "Already started" HOT 5
- Kino.Layout.grid hangs forever when you pass another Kino to it HOT 1
- Kino input field not appearing (bug?) HOT 1
- Add a process tracing JS.Live widget
- Add Kino.LiveFrame HOT 1
- Add clients monitoring
- Custom Message in `Kino.Process.seq_trace` HOT 2
- Sortable columns for Kino.DataTable
- Add Kino.Hub.on_join HOT 13
- Trouble Switching Tabs HOT 1
- We really miss this feature. Maybe we'll reopen an issue HOT 2
- Issue with Kino.JS.Live.Server.init/1 not shutting down properly HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kino.