Skip to content

Commit bfabf9d

Browse files
chore(docs): add docstring explaining streaming pattern (#205)
1 parent 2afdedd commit bfabf9d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/ssestream/ssestream.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ func NewStream[T any](decoder Decoder, err error) *Stream[T] {
131131
}
132132
}
133133

134+
// Next returns false if the stream has ended or an error occurred.
135+
// Call Stream.Current() to get the current value.
136+
// Call Stream.Err() to get the error.
137+
//
138+
// for stream.Next() {
139+
// data := stream.Current()
140+
// }
141+
//
142+
// if stream.Err() != nil {
143+
// ...
144+
// }
134145
func (s *Stream[T]) Next() bool {
135146
if s.err != nil {
136147
return false

0 commit comments

Comments
 (0)