ObserveEndOfFile implemented
This commit is contained in:
@ -7,6 +7,18 @@ import (
|
||||
"git.milar.in/milarin/channel"
|
||||
)
|
||||
|
||||
func ObserveEndOfFile(ctx context.Context, socket string) (<-chan string, error) {
|
||||
ch, err := ObserveEvent[any](ctx, socket, "end-file")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
getReason := func(e Event[any]) string { return e.Reason }
|
||||
notEmpty := func(str string) bool { return str != "" }
|
||||
reasons := channel.Filter(channel.MapSuccessive(ch, getReason), notEmpty)
|
||||
return reasons, nil
|
||||
}
|
||||
|
||||
func ObserveDisplayNames(ctx context.Context, socket string) (<-chan []string, error) {
|
||||
return ObserveProperty[[]string](ctx, socket, "display-names")
|
||||
}
|
||||
|
Reference in New Issue
Block a user