thomas9911 / streaming_frontend_ex

Define an app in an elixir file (inspired by streamlit)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StreamingFrontendEx

Installation

def deps do
  [
    {:streaming_frontend_ex, "~> 0.1.0"}
  ]
end

Getting started

There are three method of using this library.

  1. Using app with an callback function to define your app
Mix.install([:streaming_frontend_ex])

StreamingFrontendEx.app(fn ->
  StreamingFrontendEx.title("Hello World")
  StreamingFrontendEx.write("This is a nice app!")
end)

This can be run with elixir <your_file>.exs.

  1. Using an app with a supervisor

Add this to your supervisor:

 children = [
    {StreamingFrontendEx, app: {MyApp, :app, []}}
  ]

Here the MyApp module contains an app function that contains the definition.

for example:

defmodule MyApp do
  # using import here so the functions can just be called without the module
  import StreamingFrontendEx, only: [write: 1: title: 1]

  def app do
    title("Hello World")
    write("This is a nice app!")
  end
end
  1. Dynamically

If you want this you don't specific an app parameter in the supervisor and call the functions in your code.

TODO think of a better name?

About

Define an app in an elixir file (inspired by streamlit)


Languages

Language:Elixir 95.9%Language:HTML 4.1%