@@ -17,26 +17,24 @@ type Registry(name, group, message) =
17
17
18
18
/// This is the message type used internally by Chip.
19
19
///
20
- /// Its generics ` name`, ` group`, and ` msg` correspond to whatever types we do want to assign to the
21
- /// registry when initializing. A Chip instance only accepts ` Subject's of the same type so it is
22
- /// sometimes useful to state the types on startup. For example:
20
+ /// `Message( name, group, msg)` generics correspond to the types that the registry will use to manage
21
+ /// unique names, group names and Subject messages. When building your system it is useful to state
22
+ /// these on startup. For example:
23
23
///
24
24
/// ```gleam
25
25
/// type Group {
26
- /// GroupA
27
- /// GroupB
28
- /// GroupC
26
+ /// A
27
+ /// B
28
+ /// C
29
29
/// }
30
30
///
31
- /// > let assert Ok(registry) = chip.start()
32
- /// > let registry: process.Subject(chip.Message(String, Group, Chat))
31
+ /// let assert Ok(registry) = chip.start()
32
+ /// let registry: process.Subject(chip.Message(String, Group, Chat))
33
33
/// ```
34
34
///
35
35
/// By specifying the types we can document the kind of registry we are working with. For example the
36
36
/// registry above lets us tag subjects that use the `Subject(Chat)` type; it lets us tag individual
37
- /// subjects through stringified names; finally lets us group subjects into a group A, B or C.
38
- ///
39
- /// Of course we can always rely on gleam's type inference to do the typing for us.
37
+ /// subjects through stringified names; finally lets us group subjects into a groups A, B or C.
40
38
pub opaque type Message ( name, group, msg) {
41
39
NamedSubject ( client : Subject ( Result ( Subject ( msg) , Nil ) ) , name : name)
42
40
NamedRegistrant ( subject : Subject ( msg) , name : name)
@@ -135,7 +133,7 @@ pub fn group(
135
133
///
136
134
/// ```gleam
137
135
/// > chip.find(registry, "group-a")
138
- /// [subject ]
136
+ /// [subject_1, subject_2, subject_3 ]
139
137
/// ```
140
138
pub fn members ( registry , group ) -> List ( Subject ( msg) ) {
141
139
process . call ( registry , GroupedSubjects ( _, group ) , 10 )
@@ -149,6 +147,8 @@ pub fn members(registry, group) -> List(Subject(msg)) {
149
147
/// > chip.broadcast(registry, "group-a", fn(subject) {
150
148
/// > process.send(subject, Message(data))
151
149
/// > })
150
+ /// Nil
151
+ /// ```
152
152
pub fn broadcast (
153
153
registry : Subject ( Message ( name, group, message) ) ,
154
154
group : group,
0 commit comments