Documentation ¶
Overview ¶
Package base provides core fundation types and structures for haiku.
Index ¶
- Variables
- func BuildEventID(etype, eselect string) string
- func GetEventID(m EventSubs) string
- type Chain
- func (r *Chain) Bind(rnx EventHandler) Chains
- func (r *Chain) Chain(rx Chains) Chains
- func (r *Chain) HandleContext(c Event)
- func (r *Chain) NChain(rx Chains) Chains
- func (r *Chain) Next(rnx ChainHandler) Chains
- func (r *Chain) UnChain()
- func (r *Chain) UseNext(fl Chains)
- func (r *Chain) UsePrev(fl Chains)
- type ChainHandler
- type Chains
- type ElemEventMux
- type Event
- type EventActions
- type EventHandler
- type EventManager
- func (em *EventManager) AddEvent(eo EventSubs) bool
- func (em *EventManager) AddEvents(ems ...EventSubs)
- func (em *EventManager) AttachManager(esm EventManagers)
- func (em *EventManager) DetachManager(esm EventManagers)
- func (em *EventManager) DisconnectRemoved()
- func (em *EventManager) EachEvent(fx EventSubHandler)
- func (em *EventManager) EachManager(fx EventManagerHandler)
- func (em *EventManager) GetEvent(event string) (EventSubs, error)
- func (em *EventManager) HasEvent(m string) bool
- func (em *EventManager) HasManager(esm EventManagers) bool
- func (em *EventManager) LoadDOM(dom *js.Object) bool
- func (em *EventManager) LoadUpEvents()
- func (em *EventManager) NewEvent(evtype, evselector string) (EventSubs, bool)
- func (em *EventManager) NewEventMeta(meta EventMeta) (EventSubs, bool)
- func (em *EventManager) OffloadDOM()
- func (em *EventManager) RemoveEvent(event string)
- type EventManagerHandler
- type EventManagers
- type EventMeta
- type EventMetable
- type EventObject
- func (ev *EventObject) Bubbles() bool
- func (ev *EventObject) Cancelable() bool
- func (ev *EventObject) Core() *js.Object
- func (ev *EventObject) CurrentTarget() *js.Object
- func (ev *EventObject) DefaultPrevented() bool
- func (ev *EventObject) EventPhase() int
- func (ev *EventObject) PreventDefault()
- func (ev *EventObject) StopImmediatePropagation()
- func (ev *EventObject) StopPropagation()
- func (ev *EventObject) Target() *js.Object
- func (ev *EventObject) Timestamp() int
- func (ev *EventObject) Type() string
- type EventSub
- type EventSubHandler
- type EventSubs
- type JSEventMux
- type ListenerStack
Constants ¶
This section is empty.
Variables ¶
var ErrEventNotFound = errors.New("Event not found")
ErrEventNotFound is returned when an event is not found
Functions ¶
func BuildEventID ¶
BuildEventID returns the string represent of the values using the select#event format
func GetEventID ¶
GetEventID returns the id for a ElemEvent object
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain provides a simple middleware like
func (*Chain) Bind ¶
func (r *Chain) Bind(rnx EventHandler) Chains
Bind provides a wrapper over the Next binder function call
func (*Chain) Chain ¶
Chain sets the next chains else passes it down to the last chain to set as next chain,returning itself
func (*Chain) HandleContext ¶
HandleContext calls the next chain if any
func (*Chain) NChain ¶
NChain sets the next chains else passes it down to the last chain to set as next chain,returning the the supplied chain
func (*Chain) Next ¶
func (r *Chain) Next(rnx ChainHandler) Chains
Next allows the chain of the function as a Handler
func (*Chain) UnChain ¶
func (r *Chain) UnChain()
UnChain unlinks the current chain from the set and reconnects the others
type ChainHandler ¶
type ChainHandler func(Event, EventHandler)
ChainHandler provides a handler for event chain types.
type Chains ¶
type Chains interface { HandleContext(Event) Next(ChainHandler) Chains Chain(Chains) Chains NChain(Chains) Chains Bind(EventHandler) Chains UseNext(Chains) UsePrev(Chains) UnChain() }
Chains define a simple chain
func ChainIdentity ¶
func ChainIdentity() Chains
ChainIdentity returns a chain that calls the next automatically
type ElemEventMux ¶
type ElemEventMux func(Event, func())
ElemEventMux represents a stanard callback function for dom events
type Event ¶
type Event interface { Bubbles() bool Cancelable() bool CurrentTarget() *js.Object DefaultPrevented() bool EventPhase() int Target() *js.Object Timestamp() int Type() string Core() *js.Object StopPropagation() StopImmediatePropagation() PreventDefault() }
Event defines the base interface for browser events and defines the basic interface methods they must provide
type EventActions ¶
type EventActions interface { StopPropagation() bool StopImmediatePropagation() bool PreventDefault() bool }
EventActions defines standard actions for event objects.
type EventHandler ¶
type EventHandler func(Event)
EventHandler provides the function type for event callbacks when subscribing to events in Haiku.
type EventManager ¶
type EventManager struct {
// contains filtered or unexported fields
}
EventManager provides a deffered event managing sytem for registery events with
func (*EventManager) AddEvent ¶
func (em *EventManager) AddEvent(eo EventSubs) bool
AddEvent adds Event elements into the event manager if a event element is already matching that is the combination of selector#eventtype then it returns false but if added then true
func (*EventManager) AddEvents ¶
func (em *EventManager) AddEvents(ems ...EventSubs)
AddEvents adds a set of ElemEvent into the EventManager
func (*EventManager) AttachManager ¶
func (em *EventManager) AttachManager(esm EventManagers)
AttachManager allows a manager to get attached to another manajor to receive a dom binding when this receives one
func (*EventManager) DetachManager ¶
func (em *EventManager) DetachManager(esm EventManagers)
DetachManager detaches the manager if attached already
func (*EventManager) DisconnectRemoved ¶
func (em *EventManager) DisconnectRemoved()
DisconnectRemoved disconnects all events that must be removed and removes them
func (*EventManager) EachEvent ¶
func (em *EventManager) EachEvent(fx EventSubHandler)
EachEvent runnings a function over all events
func (*EventManager) EachManager ¶
func (em *EventManager) EachManager(fx EventManagerHandler)
EachManager runnings a function over all attached managers
func (*EventManager) GetEvent ¶
func (em *EventManager) GetEvent(event string) (EventSubs, error)
GetEvent returns the event if found by that id
func (*EventManager) HasEvent ¶
func (em *EventManager) HasEvent(m string) bool
HasEvent returns true/false if an event target is already marked using the format selector#eventType
func (*EventManager) HasManager ¶
func (em *EventManager) HasManager(esm EventManagers) bool
HasManager returns true/false if a manager was already attached
func (*EventManager) LoadDOM ¶
func (em *EventManager) LoadDOM(dom *js.Object) bool
LoadDOM passes down the dom element to all EventSub to initialize and listen for their respective events
func (*EventManager) LoadUpEvents ¶
func (em *EventManager) LoadUpEvents()
LoadUpEvents registers the events into the dom object
func (*EventManager) NewEvent ¶
func (em *EventManager) NewEvent(evtype, evselector string) (EventSubs, bool)
NewEvent allows the adding of event using string values
func (*EventManager) NewEventMeta ¶
func (em *EventManager) NewEventMeta(meta EventMeta) (EventSubs, bool)
NewEventMeta allows the adding of event using string values
func (*EventManager) OffloadDOM ¶
func (em *EventManager) OffloadDOM()
OffloadDOM deregisters the dom and offloads its events to allow other dom to be attached. Must call this first before try to use LoadDOM if the EventManager already is loaded
func (*EventManager) RemoveEvent ¶
func (em *EventManager) RemoveEvent(event string)
RemoveEvent removes a event from the list
type EventManagerHandler ¶
type EventManagerHandler func(EventManagers)
EventManagerHandler provides a event type callback for EventManagers.
type EventManagers ¶
type EventManagers interface { HasEvent(m string) bool GetEvent(event string) (EventSubs, error) NewEventMeta(EventMeta) (EventSubs, bool) NewEvent(evtype, evselector string) (EventSubs, bool) AttachManager(EventManagers) DetachManager(EventManagers) HasManager(EventManagers) bool RemoveEvent(event string) AddEvent(EventSubs) bool AddEvents(...EventSubs) EachEvent(EventSubHandler) EachManager(EventManagerHandler) DisconnectRemoved() OffloadDOM() LoadUpEvents() LoadDOM(dom *js.Object) bool }
EventManagers defines the Event.EventManager interface type and is used to clean up import path usage and standardize the api
func NewEventManager ¶
func NewEventManager() EventManagers
NewEventManager returns a new event manager instance
type EventMeta ¶
type EventMeta interface { EventActions Type() string Target() string Removed() bool Remove() }
EventMeta provides a basic information about the events and what its targets
type EventMetable ¶
type EventMetable struct { EventType string EventTarget string ShouldStopPropagation bool ShouldStopImmediatePropagation bool ShouldPreventDefault bool ShouldRemove bool }
EventMetable provides a concrete structural implementation of the EventMeta interface.
func (*EventMetable) PreventDefault ¶
func (e *EventMetable) PreventDefault() bool
PreventDefault returns the true/false if event should prevent its default behaviour.
func (*EventMetable) Remove ¶
func (e *EventMetable) Remove()
Remove sets the event meta as removed.
func (*EventMetable) Removed ¶
func (e *EventMetable) Removed() bool
Removed returns true/false if the event meta is marked removed.
func (*EventMetable) StopImmediatePropagation ¶
func (e *EventMetable) StopImmediatePropagation() bool
StopImmediatePropagation returns the true/false if event should stop immediate propagation.
func (*EventMetable) StopPropagation ¶
func (e *EventMetable) StopPropagation() bool
StopPropagation returns the true/false if event should stop propagation.
func (*EventMetable) Target ¶
func (e *EventMetable) Target() string
Target returns the target of event.
type EventObject ¶
EventObject implements the Event interface and is embedded by concrete event types.
func (*EventObject) Bubbles ¶
func (ev *EventObject) Bubbles() bool
Bubbles returns true/false if the event can bubble up
func (*EventObject) Cancelable ¶
func (ev *EventObject) Cancelable() bool
Cancelable returns true/false if the event is cancelable
func (*EventObject) Core ¶
func (ev *EventObject) Core() *js.Object
Core returns the internal js object for the event
func (*EventObject) CurrentTarget ¶
func (ev *EventObject) CurrentTarget() *js.Object
CurrentTarget returns the current target of the event when received
func (*EventObject) DefaultPrevented ¶
func (ev *EventObject) DefaultPrevented() bool
DefaultPrevented returns true/false if the event was prevented
func (*EventObject) EventPhase ¶
func (ev *EventObject) EventPhase() int
EventPhase returns the state of the event
func (*EventObject) PreventDefault ¶
func (ev *EventObject) PreventDefault()
PreventDefault prevents the default value of the event
func (*EventObject) StopImmediatePropagation ¶
func (ev *EventObject) StopImmediatePropagation()
StopImmediatePropagation stops the propagation of the event forcefully
func (*EventObject) StopPropagation ¶
func (ev *EventObject) StopPropagation()
StopPropagation stops the propagation of the event
func (*EventObject) Target ¶
func (ev *EventObject) Target() *js.Object
Target returns the target of the event as a js.Object
func (*EventObject) Timestamp ¶
func (ev *EventObject) Timestamp() int
Timestamp returns the event timestamp value as a int (in seconds)
type EventSub ¶
EventSub represent a single event configuration for dom.Elem objects instance which allows chaining of events listeners like middleware
func MetaEventSub ¶
MetaEventSub returns a new event using the supplied EventMeta
func NewEventSub ¶
NewEventSub returns a new event element config
func (*EventSub) Offload ¶
func (e *EventSub) Offload()
Offload removes all event bindings from current dom element
func (*EventSub) Trigger ¶
Trigger provides bypass for triggering this event sub by passing down an event directly without matching target or selector
func (*EventSub) TriggerMatch ¶
TriggerMatch check if the current event from a specific parent matches the eventarget by using the eventsub selector,if the target is within the results for that selector then it triggers the event subscribers
type EventSubHandler ¶
type EventSubHandler func(EventSubs)
EventSubHandler provides a event type callback for EventSubs.
type JSEventMux ¶
JSEventMux represents a js.listener function which is returned when attached using AddEventListeners and is used for removals with RemoveEventListeners
type ListenerStack ¶
type ListenerStack struct {
// contains filtered or unexported fields
}
ListenerStack provides addition of functions into a stack
func NewListenerStack ¶
func NewListenerStack() *ListenerStack
NewListenerStack returns a new ListenerStack instance
func (*ListenerStack) Add ¶
func (f *ListenerStack) Add(fx ElemEventMux) int
Add adds a function into the stack
func (*ListenerStack) DeleteIndex ¶
func (f *ListenerStack) DeleteIndex(ind int)
DeleteIndex removes the function at the provided index
func (*ListenerStack) Each ¶
func (f *ListenerStack) Each(d Event)
Each runs through the function lists and executing with args
func (*ListenerStack) Size ¶
func (f *ListenerStack) Size() int
Size returns the total number of listeners