Documentation

Overview

    Package split provides a module that splits the output from an existing module and sends it to two new modules. This can be useful for modules that display a lot of information, by allowing some of the module output to be placed elsewhere, typically somewhere in a group that only shows it when requested.

    For example, an email module may support multiple folders, so it could be configured to output one segment per folder, inbox coming first. It can then be split at 1, to provide a summary for just inbox, and a detail for all other folders, with the detail module placed in a collapsible group.

    labels := []string{"INBOX", "OUTBOX", "To-Do", "Follow-Up"}
    mail := mailProvider.New(labels...).
    	Output(func(m mailProvider.Info) bar.Output {
    		o := outputs.Group()
    		for _, lbl := range labels {
    			o.Append(outputs.Textf("%d", m[lbl]))
    		}
    		return o
    	})
    inbox, others := split.SplitModule(mail, 1)
    

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func New

    func New(original bar.Module, n int) (first, rest bar.Module)

      New splits the output from a module at index n, and returns two modules. The first module displays segments 0 through n (inclusive), while the second module displays all remaining segments. One or both of the modules will show an empty output if there are not enough segments in the original output.

      Types

      This section is empty.

      Source Files