radiate

Types

Opaque builder type for reloader. Create with new.

pub opaque type Builder(
  state,
  has_dirs,
  has_initializer,
  has_callback,
)

Phantom type to indicate builder has callback

pub type HasCallback

Phantom type to indicate directories have been added

pub type HasDirectories

Phantom type to indicate builder has initializer

pub type HasInitializer

Phantom type to indicate builder has no callback

pub type NoCallback

Phantom type to indicate no directories are added

pub type NoDirectories

Phantom type to indicate builder has no initializer

pub type NoInitializer

Functions

pub fn add_dir(
  builder: Builder(a, b, c, d),
  dir: String,
) -> Builder(a, HasDirectories, c, d)

Add a directory to watch. The path can be relative or absolute. macOS users: always use "." or an absolute path, otherwise it won’t work properly!

pub fn new() -> Builder(
  Nil,
  NoDirectories,
  NoInitializer,
  NoCallback,
)

Construct a new builder

pub fn on_reload(
  builder: Builder(a, b, c, NoCallback),
  callback: fn(a, String) -> a,
) -> Builder(a, b, c, HasCallback)

Add a callback to be run after reload

pub fn set_initializer(
  builder: Builder(a, b, NoInitializer, c),
  initializer: fn() -> a,
) -> Builder(a, b, HasInitializer, c)

Add an initializer

This will be run in the file watcher process, so it can be useful to, for example, add state to an actor

pub fn start(
  builder: Builder(Nil, HasDirectories, NoInitializer, a),
) -> Result(Subject(Change(Nil)), StartError)

Start reloader, if no state has been set

pub fn start_state(
  builder: Builder(a, HasDirectories, HasInitializer, b),
) -> Result(Subject(Change(Nil)), StartError)

Start reloader, ensuring that a state has been set

Search Document