Documentation ¶
Overview ¶
Package gu provides a UI framework for Go.
Index ¶
- func NewKey() string
- type AppJSON
- type AppUpdate
- type AppUpdateHandler
- type AppUpdateNotification
- type AppUpdateSubscriber
- type ApplyView
- type Component
- type Identity
- type Location
- type MarkupRenderer
- type NApp
- func (app *NApp) ActivateRoute(es interface{})
- func (app *NApp) Active() bool
- func (app *NApp) AddAsset(asset *trees.Markup, target ViewTarget)
- func (app *NApp) Do(appFun func(*NApp)) *NApp
- func (app *NApp) InitApp(location Location)
- func (app *NApp) Location() router.PushEvent
- func (app *NApp) Mounted()
- func (app *NApp) Navigate(pe router.PushDirectiveEvent)
- func (app *NApp) PushViews(event router.PushEvent) []*NView
- func (app *NApp) Render(es interface{}) *trees.Markup
- func (app *NApp) RenderJSON(es interface{}) AppJSON
- func (app *NApp) Resources() ([]*trees.Markup, []*trees.Markup)
- func (app *NApp) UUID() string
- func (app *NApp) View(renderable interface{}, route string, target ViewTarget) *NView
- type NView
- func (v *NView) Component(renderable interface{}, order RenderingOrder, route string, target string)
- func (v *NView) Disabled() bool
- func (v *NView) Do(viewFun func(*NView)) *NView
- func (v *NView) Mounted()
- func (v *NView) Render() *trees.Markup
- func (v *NView) RenderJSON() ViewJSON
- func (v *NView) Rendered()
- func (v *NView) Services() Services
- func (v *NView) Target() ViewTarget
- func (v *NView) UUID() string
- func (v *NView) Unmounted()
- func (v *NView) Updated()
- type NoopLocation
- type Properties
- type Reactive
- type Reactor
- type RenderCommand
- type Renderable
- type RenderableData
- type Renderables
- type RenderingOrder
- type Services
- type StaticView
- type Subscription
- type Subscriptions
- type ViewJSON
- type ViewTarget
- type ViewUpdate
- type ViewUpdateHandler
- type ViewUpdateNotification
- type ViewUpdateSubscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppJSON ¶
type AppJSON struct { AppID string `json:"AppId"` Name string `json:"Name"` Title string `json:"Title"` Head []ViewJSON `json:"Head"` Body []ViewJSON `json:"Body"` HeadResources []trees.MarkupJSON `json:"HeadResources"` BodyResources []trees.MarkupJSON `json:"BodyResources"` }
AppJSON defines a struct which holds the giving sets of tree changes to be rendered.
type AppUpdate ¶
type AppUpdate struct {
App *NApp
}
AppUpdate defines a struct which is used to notify the need to update a App. @notification:event
type AppUpdateHandler ¶
type AppUpdateHandler struct {
// contains filtered or unexported fields
}
AppUpdateHandler defines a structure type which implements the AppUpdateSubscriber interface and the EventDistributor interface.
func NewAppUpdateHandler ¶
func NewAppUpdateHandler(fn func(AppUpdate)) *AppUpdateHandler
NewAppUpdateHandler returns a new instance of a AppUpdateHandler.
func (*AppUpdateHandler) Handle ¶
func (sn *AppUpdateHandler) Handle(receive interface{})
Handle takes the giving value and asserts the expected value to match the AppUpdate type then passes it to the Receive method.
func (*AppUpdateHandler) Receive ¶
func (sn *AppUpdateHandler) Receive(elem AppUpdate)
Receive takes the giving value and execute it against the underline handler.
type AppUpdateNotification ¶
type AppUpdateNotification struct {
// contains filtered or unexported fields
}
AppUpdateNotification defines a structure type which must be used to receive AppUpdate type has a event.
func NewAppUpdateNotification ¶
func NewAppUpdateNotification() *AppUpdateNotification
NewAppUpdateNotification returns a new instance of NewAppUpdateNotification.
func NewAppUpdateNotificationWith ¶
func NewAppUpdateNotificationWith(validation func(AppUpdate) bool) *AppUpdateNotification
NewAppUpdateNotificationWith returns a new instance of AppUpdateNotification.
func (*AppUpdateNotification) Handle ¶
func (sn *AppUpdateNotification) Handle(elem interface{})
Handle takes the giving value and asserts the expected value to be of the type and pass on to it's underline subscribers else ignoring the event.
func (*AppUpdateNotification) Notify ¶
func (sn *AppUpdateNotification) Notify(sub AppUpdateSubscriber)
Notify adds the given subscriber into the notification list and will await an update of a new event of the given AppUpdate type.
func (*AppUpdateNotification) UnNotify ¶
func (sn *AppUpdateNotification) UnNotify(sub AppUpdateSubscriber)
UnNotify removes the given subscriber from the notification's list if found from future events.
type AppUpdateSubscriber ¶
type AppUpdateSubscriber interface {
Receive(AppUpdate)
}
AppUpdateSubscriber defines a interface that which is used to subscribe specifically for events AppUpdate type.
type ApplyView ¶
type ApplyView struct { Morph bool Mounted Subscriptions Rendered Subscriptions Content trees.Appliable // contains filtered or unexported fields }
ApplyView defines a MarkupRenderer implementing structure which returns its Content has its markup.
func ApplyStatic ¶
ApplyStatic defines a toplevel function which returns a new instance of a StaticView using the provided markup as its content.
func (*ApplyView) RenderHTML ¶
RenderHTML returns the html template version of the StaticView content.
type Component ¶
type Component struct { Reactive Target string Rendering Renderable Router router.Resolver // contains filtered or unexported fields }
Component defines a struct which
type Identity ¶
type Identity interface {
UUID() string
}
Identity defines an interface which expoese the identity of a giving object.
type Location ¶
type Location interface { // Current Location of the driver path. Location() router.PushEvent Navigate(router.PushDirectiveEvent) }
Location defines an interface which exposes a type which allows the retrieval and setting of the location of a given display.
type MarkupRenderer ¶
type MarkupRenderer interface { Renderable RenderHTML() template.HTML }
MarkupRenderer provides a interface for a types capable of rendering dom markup.
type NApp ¶
type NApp struct {
// contains filtered or unexported fields
}
NApp defines a struct which encapsulates all the core view management functions for views.
func (*NApp) ActivateRoute ¶
func (app *NApp) ActivateRoute(es interface{})
ActivateRoute actives the views which are to be rendered.
func (*NApp) Active ¶
Active returns true/false if the giving app is active and has already received rendering.
func (*NApp) AddAsset ¶
func (app *NApp) AddAsset(asset *trees.Markup, target ViewTarget)
AddAsset adds giving tree.Markup has assets to be loaded either in the head or body based on the posiiton desired.
func (*NApp) InitApp ¶
InitApp sets the Location to be used by the NApp and it's views and components.
func (*NApp) Location ¶
Location returns the current route. It stores all set routes and returns the last route else returning a
func (*NApp) Mounted ¶
func (app *NApp) Mounted()
Mounted notifies all active views that they have been mounted.
func (*NApp) Navigate ¶
func (app *NApp) Navigate(pe router.PushDirectiveEvent)
Navigate sets the giving app location and also sets the location of the NOOPLocation which returns that always.
func (*NApp) Render ¶
Render returns the giving rendered tree of the app respective of the path found.
func (*NApp) RenderJSON ¶
RenderJSON returns the giving rendered tree of the app respective of the path found as jons structure with markup content.
type NView ¶
type NView struct { Reactive // contains filtered or unexported fields }
NView defines a structure to encapsulates all rendering component for a given view.
func (*NView) Component ¶
func (v *NView) Component(renderable interface{}, order RenderingOrder, route string, target string)
Component adds the provided component into the selected view.
func (*NView) Mounted ¶
func (v *NView) Mounted()
Mounted publishes changes notifications that the view is mounted.
func (*NView) RenderJSON ¶
RenderJSON returns the ViewJSON for the provided View and its current events and changes.
func (*NView) Rendered ¶
func (v *NView) Rendered()
Rendered publishes changes notifications that the view is rendered.
func (*NView) Services ¶
Services return s a Service instance which contains fields used by the Components of a view to gain access to the specific functionality of it's app root.
func (*NView) Target ¶
func (v *NView) Target() ViewTarget
Target returns the associated view target.
type NoopLocation ¶
type NoopLocation struct {
// contains filtered or unexported fields
}
NoopLocation defines a basic struct which implements the Location interface and is used to stand in for a app when not provided one.
func NewNoopLocation ¶
func NewNoopLocation(app *NApp) *NoopLocation
NewNoopLocation returns a new instance of a NoopLocation.
func (*NoopLocation) Location ¶
func (n *NoopLocation) Location() router.PushEvent
Location returns the current route. It stores all set routes and returns the last route else returning a
func (*NoopLocation) Navigate ¶
func (n *NoopLocation) Navigate(pe router.PushDirectiveEvent)
Navigate sets the giving app location and also sets the location of the NOOPLocation which returns that always.
type Properties ¶
type Properties interface {
Get(string) interface{}
}
Properties defines a type which exposes a single method to retrieve values from.
type Reactive ¶
type Reactive interface { Reactor Publish() }
Reactive extends the ReactiveRenderable by exposing a Publish method which allows calling the update notifications list of a ReactiveRenderable.
func NewReactive ¶
func NewReactive() Reactive
NewReactive returns an instance of a Reactive struct.
type Reactor ¶
type Reactor interface {
React(func())
}
Reactor defines an interface for functions subscribing for notifications to react.
type RenderCommand ¶
type RenderCommand struct { Command string `json:"Command"` App AppJSON `json:"App,omitempty"` View ViewJSON `json:"View,omitempty"` }
RenderCommand defines a struct to hold a giving command for the rendering of a App or View using the JSON format.
func AppRenderCommand ¶
func AppRenderCommand(app *NApp, route interface{}) RenderCommand
AppRenderCommand returns a new RenderCommand for rendering a app.
func ViewRenderCommand ¶
func ViewRenderCommand(view *NView) RenderCommand
ViewRenderCommand returns a new RenderCommand for rendering a view.
type Renderable ¶
Renderable provides a interface for a renderable type.
type RenderableData ¶
RenderableData defines a struct which contains the name of a giving renderable and it's package.
type Renderables ¶
type Renderables []Renderable
Renderables defines a lists of Renderable structures.
type RenderingOrder ¶
type RenderingOrder int
RenderingOrder defines a type used to define the order which rendering is to be done for a resource.
const ( // FirstOrder defines that rendering be first in order. FirstOrder RenderingOrder = iota // AnyOrder defines that rendering be middle in order. AnyOrder // LastOrder defines that rendering be last in order. LastOrder )
type Services ¶
type Services struct { AppUUID string Location Location Mounted Subscriptions Rendered Subscriptions Updated Subscriptions Unmounted Subscriptions Router *router.Router ViewRoute router.Resolver }
Services defines a struct which exposes certain fields to be accessible to others.
type StaticView ¶
type StaticView struct { Content *trees.Markup Mounted Subscriptions Rendered Subscriptions Morph bool // contains filtered or unexported fields }
StaticView defines a MarkupRenderer implementing structure which returns its Content has its markup.
func Static ¶
func Static(tree *trees.Markup) *StaticView
Static defines a toplevel function which returns a new instance of a StaticView using the provided markup as its content.
func (*StaticView) Render ¶
func (s *StaticView) Render() *trees.Markup
Render returns the markup for the static view.
func (*StaticView) RenderHTML ¶
func (s *StaticView) RenderHTML() template.HTML
RenderHTML returns the html template version of the StaticView content.
func (*StaticView) UUID ¶
func (s *StaticView) UUID() string
UUID returns the RenderGroup UUID for identification.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription defines a baseline structure that can be composed into any struct to provide a reactive view.
func NewSubscriptions ¶
func NewSubscriptions() *Subscription
NewSubscriptions returns an instance of a Subscription pointer.
func (*Subscription) Clear ¶
func (r *Subscription) Clear()
Clear destroys all subscribers in the lists.
func (*Subscription) Publish ¶
func (r *Subscription) Publish()
Publish runs a through the subscription list and calls the registerd functions.
func (*Subscription) React ¶
func (r *Subscription) React(sub func())
React adds a function into the subscription list for this reactor.
func (*Subscription) Reset ¶
func (r *Subscription) Reset()
Reset resets the subscription has unused.
func (*Subscription) Used ¶
func (r *Subscription) Used() bool
Used returns true/false if the subscription has been called to publish.
type Subscriptions ¶
Subscriptions exposes an interface which combines a Reactive type and a clear function to dispose of subscribers.
type ViewJSON ¶
type ViewJSON struct { AppID string `json:"AppID"` ViewID string `json:"ViewID"` Tree trees.MarkupJSON `json:"Tree"` }
ViewJSON defines a struct which holds the giving sets of view changes to be rendered.
type ViewTarget ¶
type ViewTarget int
ViewTarget defines a concrete type to define where the view should be rendered.
const ( // BodyTarget defines the view target where the view is rendered in the body. BodyTarget ViewTarget = iota // HeadTarget defines the view target where the view is rendered in the head. HeadTarget // AfterBodyTarget defines the view target where the view is rendered after // body views content. Generally the browser moves anything outside of the body // into the body as last elements. So this will be the last elements rendered // in the border accordingly in the order they are added into the respective app. AfterBodyTarget )
type ViewUpdate ¶
ViewUpdate defines a struct which is used to notify the need to update a App and a given view. @notification:event
type ViewUpdateHandler ¶
type ViewUpdateHandler struct {
// contains filtered or unexported fields
}
ViewUpdateHandler defines a structure type which implements the ViewUpdateSubscriber interface and the EventDistributor interface.
func NewViewUpdateHandler ¶
func NewViewUpdateHandler(fn func(ViewUpdate)) *ViewUpdateHandler
NewViewUpdateHandler returns a new instance of a ViewUpdateHandler.
func (*ViewUpdateHandler) Handle ¶
func (sn *ViewUpdateHandler) Handle(receive interface{})
Handle takes the giving value and asserts the expected value to match the ViewUpdate type then passes it to the Receive method.
func (*ViewUpdateHandler) Receive ¶
func (sn *ViewUpdateHandler) Receive(elem ViewUpdate)
Receive takes the giving value and execute it against the underline handler.
type ViewUpdateNotification ¶
type ViewUpdateNotification struct {
// contains filtered or unexported fields
}
ViewUpdateNotification defines a structure type which must be used to receive ViewUpdate type has a event.
func NewViewUpdateNotification ¶
func NewViewUpdateNotification() *ViewUpdateNotification
NewViewUpdateNotification returns a new instance of NewViewUpdateNotification.
func NewViewUpdateNotificationWith ¶
func NewViewUpdateNotificationWith(validation func(ViewUpdate) bool) *ViewUpdateNotification
NewViewUpdateNotificationWith returns a new instance of ViewUpdateNotification.
func (*ViewUpdateNotification) Handle ¶
func (sn *ViewUpdateNotification) Handle(elem interface{})
Handle takes the giving value and asserts the expected value to be of the type and pass on to it's underline subscribers else ignoring the event.
func (*ViewUpdateNotification) Notify ¶
func (sn *ViewUpdateNotification) Notify(sub ViewUpdateSubscriber)
Notify adds the given subscriber into the notification list and will await an update of a new event of the given ViewUpdate type.
func (*ViewUpdateNotification) UnNotify ¶
func (sn *ViewUpdateNotification) UnNotify(sub ViewUpdateSubscriber)
UnNotify removes the given subscriber from the notification's list if found from future events.
type ViewUpdateSubscriber ¶
type ViewUpdateSubscriber interface {
Receive(ViewUpdate)
}
ViewUpdateSubscriber defines a interface that which is used to subscribe specifically for events ViewUpdate type.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package eventx attempts to provide a concrete go type for different events related to the DOM.
|
Package eventx attempts to provide a concrete go type for different events related to the DOM. |
Package trees is a work inspired by a experiemental package by now authors of Vecty(github.com/gopherjs/vecty), although the provide similar API, the underline nature of how gutrees behave and function is heavily different from its original.
|
Package trees is a work inspired by a experiemental package by now authors of Vecty(github.com/gopherjs/vecty), although the provide similar API, the underline nature of how gutrees behave and function is heavily different from its original. |
events
Package events defines the event binding system that combines different libraries to create a interesting event system.
|
Package events defines the event binding system that combines different libraries to create a interesting event system. |