Documentation
¶
Overview ¶
Package presenter implements the Presenter System. CRC: crc-Presenter.md, crc-AppPresenter.md, crc-ListPresenter.md Spec: main.md
Index ¶
- type AppPresenter
- func (ap *AppPresenter) Back() bool
- func (ap *AppPresenter) CurrentPage() *PageReference
- func (ap *AppPresenter) Forward() bool
- func (ap *AppPresenter) Go(index int) bool
- func (ap *AppPresenter) Navigate(url string, variableID int64)
- func (ap *AppPresenter) ReplaceCurrentPage(url string, variableID int64)
- func (ap *AppPresenter) ToData() (json.RawMessage, error)
- type ListPresenter
- func (lp *ListPresenter) AddItem(variableID int64)
- func (lp *ListPresenter) GetItems() []int64
- func (lp *ListPresenter) GetSelected() int64
- func (lp *ListPresenter) RemoveItem(variableID int64) bool
- func (lp *ListPresenter) SelectItem(variableID int64)
- func (lp *ListPresenter) ToData() (json.RawMessage, error)
- type PageReference
- type Presenter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppPresenter ¶
type AppPresenter struct {
*Presenter
URL string `json:"url"`
HistoryIndex int `json:"historyIndex"`
History []PageReference `json:"history"`
}
AppPresenter is the root presenter for a session.
func NewAppPresenter ¶
func NewAppPresenter() *AppPresenter
NewAppPresenter creates a new app presenter.
func (*AppPresenter) Back ¶
func (ap *AppPresenter) Back() bool
Back navigates to the previous page.
func (*AppPresenter) CurrentPage ¶
func (ap *AppPresenter) CurrentPage() *PageReference
CurrentPage returns the current page from history.
func (*AppPresenter) Forward ¶
func (ap *AppPresenter) Forward() bool
Forward navigates to the next page.
func (*AppPresenter) Go ¶
func (ap *AppPresenter) Go(index int) bool
Go navigates to a specific history index.
func (*AppPresenter) Navigate ¶
func (ap *AppPresenter) Navigate(url string, variableID int64)
Navigate pushes a new page to history.
func (*AppPresenter) ReplaceCurrentPage ¶
func (ap *AppPresenter) ReplaceCurrentPage(url string, variableID int64)
ReplaceCurrentPage replaces the current page without adding to history.
func (*AppPresenter) ToData ¶
func (ap *AppPresenter) ToData() (json.RawMessage, error)
ToData serializes the app presenter state.
type ListPresenter ¶
type ListPresenter struct {
*Presenter
Items []int64 `json:"items"` // Variable IDs of list items
SelectedID int64 `json:"selectedId,omitempty"`
}
ListPresenter manages a list of items.
func NewListPresenter ¶
func NewListPresenter() *ListPresenter
NewListPresenter creates a new list presenter.
func (*ListPresenter) AddItem ¶
func (lp *ListPresenter) AddItem(variableID int64)
AddItem adds an item to the list.
func (*ListPresenter) GetItems ¶
func (lp *ListPresenter) GetItems() []int64
GetItems returns all item IDs.
func (*ListPresenter) GetSelected ¶
func (lp *ListPresenter) GetSelected() int64
GetSelected returns the selected item ID.
func (*ListPresenter) RemoveItem ¶
func (lp *ListPresenter) RemoveItem(variableID int64) bool
RemoveItem removes an item from the list.
func (*ListPresenter) SelectItem ¶
func (lp *ListPresenter) SelectItem(variableID int64)
SelectItem selects an item.
func (*ListPresenter) ToData ¶
func (lp *ListPresenter) ToData() (json.RawMessage, error)
ToData serializes the list presenter state.
type PageReference ¶
PageReference refers to a page presenter.
type Presenter ¶
type Presenter struct {
Type string `json:"type"`
Data json.RawMessage `json:"data,omitempty"`
ViewName string `json:"view,omitempty"`
VariableID int64 `json:"-"`
}
Presenter represents a UI presenter.
func NewPresenter ¶
NewPresenter creates a new presenter.
func (*Presenter) GetData ¶
func (p *Presenter) GetData() json.RawMessage
GetData returns the presenter state.
func (*Presenter) GetViewName ¶
GetViewName returns the active view name.
func (*Presenter) SetData ¶
func (p *Presenter) SetData(data json.RawMessage)
SetData updates the presenter state.
func (*Presenter) SetViewName ¶
SetViewName switches to a different view.