channel

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2024 License: LGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package channel provides utilities to create an Bubbletea model compatible with Go channels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorMsg

type ErrorMsg[T any] error

ErrorMsg is a signal used to close the channel of the Model.

type Model

type Model[T any] struct {
	Channel chan T
	// OnInit is used to insert data into the channel and initialize the dispose method.
	OnInit func(chan T) func() error
	// contains filtered or unexported fields
}

Model is the object used to implement a bubbletea model with a channel.

func (*Model[T]) Dispose

func (m *Model[T]) Dispose() tea.Msg

Dispose executes the dispose function.

func (Model[T]) Init

func (m Model[T]) Init() tea.Cmd

Init emit a signal used to start listening the channel.

func (Model[T]) Update

func (m Model[T]) Update(msg tea.Msg) (Model[T], tea.Cmd)

Update prepare the dispose method and emit a tick for listening the channel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL