Documentation
¶
Index ¶
- func CurrentRoute() string
- func Destroy() tea.Msg
- func LastRoute() string
- func Navigate(target string) tea.Cmd
- func NewProgram(root Component, options ...tea.ProgramOption) *tea.Program
- func RenderAny[TProps any, TRenderer AnyRenderer[TProps]](renderer TRenderer, props TProps, width, height int) (result string)
- func RenderDumb[TRenderer AnyProplessRenderer](renderer TRenderer, width, height int) (result string)
- func Rerender() tea.Msg
- func RouteMatchesPlaceholder(route string, placeholder string) (map[string]string, bool)
- func SetRoute(target string) tea.Cmd
- func WasRouteChanged() bool
- func WithRoute(route string) func(*tea.Program)
- func WithoutInput() func(*tea.Program)
- type AnyProplessRenderer
- type AnyRenderer
- type BasicComponent
- type Component
- type DumbRenderer
- type InvisibleComponent
- type NoProps
- type ProplessRenderer
- type Reactified
- type Renderer
- type RerenderMsg
- type RouteUpdatedMsg
- type Size
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentRoute ¶
func CurrentRoute() string
func NewProgram ¶ added in v0.3.0
func NewProgram(root Component, options ...tea.ProgramOption) *tea.Program
Note: Return type is *tea.Program, Reactea doesn't have it's own wrapper (reactea.Program) type, yet (?)
func RenderAny ¶
func RenderAny[TProps any, TRenderer AnyRenderer[TProps]](renderer TRenderer, props TProps, width, height int) (result string)
Renders all AnyRenderers in one function
Note: If you are using ProplessRenderer/DumbRenderer just pass reactea.NoProps{} or struct{}{}
Note: Using named return type for 100% coverage
func RenderDumb ¶ added in v0.5.0
func RenderDumb[TRenderer AnyProplessRenderer](renderer TRenderer, width, height int) (result string)
Handles rendering of all AnyProplessRenderers in one function
Note: Using named return type for 100% coverage
func RouteMatchesPlaceholder ¶ added in v0.4.0
Checks whether route (e.g. /teams/123/12) matches placeholder (e.g /teams/:teamId/:playerId) Returns map of found params and if it matches Params have to follow regex ^:.*$ ^ being beginning of current path level (/^level/) $ being end of current path level (/level$/)
Note: Entire matched route can be accessed with key "$" Note: Placeholders can be optional => /foo/?:/?: will match foo/bar and foo and /foo/bar/baz Note: The most outside placeholders can be optional recursive => /foo/+?: will match /foo/bar and foo and /foo/bar/baz Note: It allows for defining wildcards with /foo/:/bar Note: Duplicate params will result in overwrite of first param
func WasRouteChanged ¶
func WasRouteChanged() bool
func WithoutInput ¶ added in v0.3.1
Useful for testing on Github Actions, by default Bubbletea would try reading from /dev/tty, but on Github Actions it's restricted resulting in error
Types ¶
type AnyProplessRenderer ¶ added in v0.2.0
type AnyProplessRenderer interface { ProplessRenderer | DumbRenderer }
type AnyRenderer ¶ added in v0.2.0
type AnyRenderer[TProps any] interface { func(TProps, int, int) string | AnyProplessRenderer }
Why not Renderer[TProps]? It would have to be a type alias there are no type aliases yet for generics, but they are planned for some time soon. Something to keep in mind for future
type BasicComponent ¶
type BasicComponent struct{}
Basic component that implements all methods required by reactea.Component except Render(int, int)
func (*BasicComponent) Destroy ¶
func (c *BasicComponent) Destroy()
func (*BasicComponent) Init ¶ added in v0.5.0
func (c *BasicComponent) Init() tea.Cmd
type Component ¶
type Component interface { // Init() Is meant to both initialize subcomponents and run // long IO operations through tea.Cmd Init() tea.Cmd // It's called when component is about to be destroyed Destroy() // Typical tea.Model Update(), we handle all IO events here Update(tea.Msg) tea.Cmd // Render() is called when component should render itself // Provided width and height are target dimensions Render(int, int) string }
func Componentify ¶ added in v0.2.0
func Componentify[TProps any, TRenderer AnyRenderer[TProps]](renderer TRenderer, props TProps) Component
Componentifies AnyRenderer Returns uninitialized component with renderer taking care of .Render()
func ComponentifyDumb ¶ added in v0.5.0
func ComponentifyDumb[TRenderer AnyProplessRenderer](renderer TRenderer) Component
Componentifies AnyProplessRenderer Returns uninitialized component with renderer taking care of .Render()
func StaticComponent ¶ added in v0.5.0
type DumbRenderer ¶
type DumbRenderer = func() string
Doesn't have state, props, even scalling for target dimensions = DumbRenderer, or Stringer
type InvisibleComponent ¶
type InvisibleComponent struct{}
Utility component for displaying empty string on Render()
type ProplessRenderer ¶
SUPEEEEEER shorthand for components
func PropfulToLess ¶
func PropfulToLess[TProps any](renderer Renderer[TProps], props TProps) ProplessRenderer
Wraps propful into propless renderer
type Reactified ¶ added in v0.5.0
Reactifies Bubbletea's models into reactea's components
type Renderer ¶
Ultra shorthand for components = just renderer One could say it's a stateless component Also note that it doesn't handle any IO by itself
TODO: Change to type alias after type aliases for generics support is implemented. For now explicit type conversion is required
type RerenderMsg ¶ added in v0.5.0
type RerenderMsg struct{}
type RouteUpdatedMsg ¶ added in v0.5.0
type RouteUpdatedMsg struct {
Original string
}