livebook/lib/live_book/notebook/section.ex
Jonatan Kłosko 00b06f6e7a
Define session data structure and implement several operations (#6)
* Define session data structure and some operations

* Make code evaluation request async, so that we don't need an intermediary process

* Simplify id typespecs

* Make operation application composable

* Keep a separate evaluation queue per section and actually support concurrent evaluation

* Small fixes

* Validate queued cell type and set evaluation timestamp

* Apply review suggestions

* Add tests

* Store evaluating_cell_id instead of section status

* Add dynamic supervisor for managing evaluator processes

* Some fixes

* Refactor operation application

* Upon cell deletion mark dependent cells as stale
2021-01-13 14:39:04 +01:00

35 lines
742 B
Elixir

defmodule LiveBook.Notebook.Section do
@moduledoc """
Data structure representing a single section in a notebook.
Each section contains a number of cells and is isolated
in the sense that cells don't interfere with cells in other sections.
"""
defstruct [:id, :name, :cells, :metadata]
alias LiveBook.Notebook.Cell
alias LiveBook.Utils
@type id :: Utils.id()
@type t :: %__MODULE__{
id: id(),
name: String.t(),
cells: list(Cell.t()),
metadata: %{atom() => term()}
}
@doc """
Returns a blank section.
"""
@spec new() :: t()
def new() do
%__MODULE__{
id: Utils.random_id(),
name: "Section",
cells: [],
metadata: %{}
}
end
end