Documentation
¶
Index ¶
- func AfterUpdate(afterUpdater AfterUpdater)
- func Destroy() tea.Msg
- func New(root Component[NoProps]) model
- func RenderAny[TRenderer AnyComponent[TProps], TProps any](renderer TRenderer, props TProps, width, height int) string
- func RenderPropless[TRenderer AnyProplessComponent](renderer TRenderer, width, height int) string
- func SetCurrentRoute(r Route)
- func WasRouteChanged() bool
- type AfterUpdater
- type AnyComponent
- type AnyProplessComponent
- type BasicComponent
- type BasicPropfulComponent
- type Component
- type DumbRenderer
- type InvisibleComponent
- type NoProps
- type ProplessRenderer
- type Renderer
- type Route
- type SomeComponent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterUpdate ¶
func AfterUpdate(afterUpdater AfterUpdater)
Queue component for AfterUpdate event
func RenderAny ¶
func RenderAny[TRenderer AnyComponent[TProps], TProps any](renderer TRenderer, props TProps, width, height int) string
I'm sorry gophers, I did it for compile-time safety Hopefully nobody is ever gonna get headache because of this
func RenderPropless ¶
func RenderPropless[TRenderer AnyProplessComponent](renderer TRenderer, width, height int) string
I'm sorry gophers, I did it for compile-time safety Hopefully nobody is ever gonna get headache because of this
func SetCurrentRoute ¶
func SetCurrentRoute(r Route)
func WasRouteChanged ¶
func WasRouteChanged() bool
Types ¶
type AfterUpdater ¶
type AnyComponent ¶
type AnyComponent[TProps any] interface { Renderer[TProps] | AnyProplessComponent }
I decided to give it a name "Component" and not "Renderer" Because Component.Render is itself ProplessRenderer (or the other way around ProplessRenderer = Component.Render) So the naming is infact valid for any type of components in reactea
type AnyProplessComponent ¶
type AnyProplessComponent interface {
ProplessRenderer | DumbRenderer
}
I decided to give it a name "Component" and not "Renderer" Because Component.Render is itself ProplessRenderer (or the other way around ProplessRenderer = Component.Render) So the naming is infact valid for any type of components in reactea
type BasicComponent ¶
type BasicComponent struct{}
The most basic form of reactea component It implements all not required methods so you don't have to
func (*BasicComponent) AfterUpdate ¶
func (c *BasicComponent) AfterUpdate() tea.Cmd
func (*BasicComponent) Destroy ¶
func (c *BasicComponent) Destroy()
type BasicPropfulComponent ¶
type BasicPropfulComponent[TProps any] struct { // contains filtered or unexported fields }
Stores props in struct. If you want to derive state from UpdateProps() you're probably looking at wrong thing
func (*BasicPropfulComponent[TProps]) Init ¶
func (c *BasicPropfulComponent[TProps]) Init(props TProps) tea.Cmd
func (*BasicPropfulComponent[TProps]) Props ¶
func (c *BasicPropfulComponent[TProps]) Props() TProps
func (*BasicPropfulComponent[TProps]) UpdateProps ¶
func (c *BasicPropfulComponent[TProps]) UpdateProps(props TProps)
type Component ¶
type Component[TProps any] interface { // You always have to initialize component with some kind of // props - it can even be zero value // Init() Is meant to both initialize subcomponents and run // long IO operations through tea.Cmd Init(TProps) tea.Cmd // It's called when component is about to be destroyed // // Note: It's parent component job to call it and // relying on it outside of reactea builtins is // not reliable Destroy() // Typical tea.Model Update(), we handle all IO events here Update(tea.Msg) tea.Cmd // Callee already knows at which size should it render at Render(int, int) string // It's an Update() but for props, the state derive stage // happens here UpdateProps(TProps) // AfterUpdate is stage useful for components like routers // to prepare content. Saying that you will probably never // need to use it AfterUpdate() tea.Cmd }
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
Wrapper function
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
type SomeComponent ¶
type SomeComponent interface {
Destroy()
Update(tea.Msg) tea.Cmd
Render(int, int) string
AfterUpdate() tea.Cmd
}
Interface which is basically reactea.Component just without the props part
func PropfulToComponent ¶
func PropfulToComponent[TProps any](renderer Renderer[TProps], props TProps) SomeComponent
func ProplessToComponent ¶
func ProplessToComponent(renderer ProplessRenderer) SomeComponent