chouzar / chip

Registry library for gleam
15 stars 2 forks source link

Extend API ideas #4

Closed chouzar closed 2 days ago

chouzar commented 5 months ago
// Retrieves all tags on the registry.
/// 
/// ## Example
/// 
/// ```gleam
/// let assert Ok(registry) = chip.start()
/// 
/// let assert [_tag, ..tags] = chip.tags(registry)
/// ```
pub fn tags(registry: Registry(msg, tag, group)) -> List(tag) {
  // TODO: May be obtained from ETS directly
  todo
}

/// Retrieves all groups on the registry.
/// 
/// ## Example
/// 
/// ```gleam
/// let assert Ok(registry) = chip.start()
/// 
/// let assert [_group, ..groups] = chip.groups(registry)
/// ```
pub fn groups(registry: Registry(msg, tag, group)) -> List(group) {
  // TODO: May be obtained from ETS directly
  todo
}

/// Returns registry datapoints like a list of tags, groups, number of registered subjects. 
/// Maybe some insight into the consumed memory (state + selectors) 
/// Information on the different tables and records in them.
pub fn info(registry: Registry(msg, tag, group)) {
  todo
}
chouzar commented 2 months ago
/// Adds default metadata for a registration. Which may be later accessed on a dispatch.
pub fn meta(registrant: Chip(msg, tag, group), metadata: metadata) {
  todo
}

/// Like dispatch but this avoids side-effects by producing an up-front message. 
/// Hesistant on this one as this wont work for protected Message types.
pub fn broadcast(registry: Registry(msg, tag, group), message: msg) -> Nil {
  todo
}

/// Similar to above but receives metadata to generate the message.
pub fn broadcast(registry: Registry(msg, tag, group), message: fn(metadata) -> message) -> Nil {
  todo
}
chouzar commented 2 days ago

Divided into multiple issues.