Giter VIP home page Giter VIP logo

Comments (5)

jonatanklosko avatar jonatanklosko commented on July 30, 2024 1

@NduatiK you can do this:

if HTTPPort.in_use?(default_port) do
  kill? = Kino.Shorts.read_checkbox("Kill port 4000")

  if kill? do
    HTTPPort.kill_process(default_port)
  else
    Kino.interrupt!(:normal, "Port 4000 is taken")
  end
end

Since you start the LVN server in the notebook, it would make sense to pick a more random port, so it's much less likely that people run into conflict :)

from kino.

josevalim avatar josevalim commented on July 30, 2024

At first I am 👎 because if you need to perform such tasks, it means you are generally unable to reevaluate the cell in the first place? Can you provide a more concrete example? Who is using that Port? Where and how was it started?

from kino.

NduatiK avatar NduatiK commented on July 30, 2024

Sure thing.

I mean that there is a system process somewhere that is making use of the HTTP port (not Elixir port 🙃).

Let's say that a new Elixir developer has run mix phx.server from their terminal.
If they attempts to start one of LiveView Native's tutorials, we would like to tell them that the default port used by LiveView Native (4000) is in use and offer to kill the system process holding the port.

The idea is that to block the execution until that system process is killed, and to offer the user a way to kill it.
Kino.interrupt! currently lets us block execution if some condition is not met. It would be nice to be able to execute some code before attempting to reevaluate the code.

from kino.

NduatiK avatar NduatiK commented on July 30, 2024

Another use case would be in allowing developers to specify potentially destructive actions that needs confirmation.

For example, imagine we are using a Livebook app to send out daily emails.
In general we might always allow emails to go out. But if we detect that a user is sending the second email of the day, we might want to them to confirm that they really do want to send it.

from kino.

NduatiK avatar NduatiK commented on July 30, 2024

@jonatanklosko, we came up with a similar workaround, but yours is much cleaner.

Thanks!

from kino.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.