chouzar / chip

Registry library for gleam
15 stars 2 forks source link

Add a Task based dispatch mechanism #3

Open chouzar opened 5 months ago

chouzar commented 5 months ago

Dispatching to subjects in the registry should be done in independent tasks.

chouzar commented 2 months ago

Added a dispatch in ea8990e0ebec334366696a91b9f2914a292ac122 it is very fragile.

chouzar commented 3 days ago

Had to re-think how to dispatch tasks to multiple subjects in the registry, this signature should be a good starting point:

/// Applies a callback over a group.
/// 
/// ## Example
/// 
/// ```gleam
/// chip.dispatch_group(registry, Pets, fn(subject) { 
///   process.send(subject, message)
/// })
/// ```
pub fn dispatch(
  registry: Registry(msg, group),
  group: group,
  callback: fn(process.Subject(msg)) -> x,
) -> Nil {
  todo
}

The previous implementation can be found at v0.9.0.