radiate

Types

Opaque builder type for reloader. Create with new.

pub opaque type Builder(state, has_dirs, has_initializer)

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 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),
  dir: String,
) -> Builder(a, HasDirectories, c)
pub fn new() -> Builder(Nil, NoDirectories, NoInitializer)

Construct a new builder

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

Add a callback to be run after reload

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

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),
) -> Result(Subject(Change), StartError)

Start reloader, if no state has been set

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

Start reloader, ensuring that a state has been set

Search Document