Documentation
¶
Overview ¶
Package doors builds server-rendered web apps with typed routing, reactive state, and server-handled browser interactions.
Most apps start with NewRouter, register one or more page models with UseModel, and render dynamic fragments with Door, Source, and Beam. Event attrs such as AClick, ASubmit, and ALink connect DOM events, forms, and navigation to Go handlers while still producing regular HTML.
For a guided introduction, see the documents embedded in DocsFS.
Index ¶
- Variables
- func Call(ctx context.Context, action Action) context.CancelFunc
- func Free(ctx context.Context) context.Context
- func Go(f func(context.Context)) gox.Editor
- func IDBytes(b []byte) string
- func IDRand() string
- func IDString(string string) string
- func Inject[T any](key any, beam Beam[T]) gox.Proxy
- func InstanceEnd(ctx context.Context)
- func InstanceId(ctx context.Context) string
- func SessionEnd(ctx context.Context)
- func SessionExpire(ctx context.Context, d time.Duration)
- func SessionId(ctx context.Context) string
- func Status(statusCode int) gox.Editor
- func Sub[T any](beam Beam[T], el func(T) gox.Elem) gox.EditorComp
- func UseCSP(r Router, csp CSP)
- func UseESConf(r Router, conf ESConf)
- func UseErrorPage(r Router, page func(l Location, err error) gox.Comp)
- func UseFallback(r Router, handler http.Handler)
- func UseLicence(r Router, license string)
- func UseLicense(r Router, license string)
- func UseModel[M any](r Router, handler func(r RequestModel, s Source[M]) Response)
- func UseRoute(r Router, rt Route)
- func UseServerID(r Router, id string)
- func UseSessionCallback(r Router, callback SessionCallback)
- func UseSystemConf(r Router, conf SystemConf)
- func XCall[T any](ctx context.Context, action Action) (<-chan CallResult[T], context.CancelFunc)
- type ABlur
- type AChange
- type AClick
- type AData
- type AFocus
- type AFocusIn
- type AFocusOut
- type AGotPointerCapture
- type AHook
- type AInput
- type AKeyDown
- type AKeyUp
- type ALink
- type ALostPointerCapture
- type APointerCancel
- type APointerDown
- type APointerEnter
- type APointerLeave
- type APointerMove
- type APointerOut
- type APointerOver
- type APointerUp
- type ARawHook
- type ARawSubmit
- type AShared
- type ASubmit
- type Action
- func ActionOnlyEmit(name string, arg any) []Action
- func ActionOnlyIndicate(indicator []Indicator, duration time.Duration) []Action
- func ActionOnlyLocationAssign(model any) []Action
- func ActionOnlyLocationRawAssign(url string) []Action
- func ActionOnlyLocationReload() []Action
- func ActionOnlyLocationReplace(model any) []Action
- func ActionOnlyScroll(selector string) []Action
- type ActionEmit
- type ActionIndicate
- type ActionLocationAssign
- type ActionLocationRawAssign
- type ActionLocationReload
- type ActionLocationReplace
- type ActionScroll
- type Active
- type Attr
- type Beam
- type CSP
- type CallResult
- type ChangeEvent
- type Door
- type ESConf
- type ESOptions
- type FocusEvent
- type HrefActiveMatch
- type Indicator
- func IndicatorOnlyAttr(attr string, value string) []Indicator
- func IndicatorOnlyAttrQuery(query string, attr string, value string) []Indicator
- func IndicatorOnlyAttrQueryAll(query string, attr string, value string) []Indicator
- func IndicatorOnlyAttrQueryParent(query string, attr string, value string) []Indicator
- func IndicatorOnlyClass(class string) []Indicator
- func IndicatorOnlyClassQuery(query string, class string) []Indicator
- func IndicatorOnlyClassQueryAll(query string, class string) []Indicator
- func IndicatorOnlyClassQueryParent(query string, class string) []Indicator
- func IndicatorOnlyClassRemove(class string) []Indicator
- func IndicatorOnlyClassRemoveQuery(query string, class string) []Indicator
- func IndicatorOnlyClassRemoveQueryAll(query string, class string) []Indicator
- func IndicatorOnlyClassRemoveQueryParent(query string, class string) []Indicator
- func IndicatorOnlyContent(content string) []Indicator
- func IndicatorOnlyContentQuery(query string, content string) []Indicator
- func IndicatorOnlyContentQueryAll(query string, content string) []Indicator
- func IndicatorOnlyContentQueryParent(query string, content string) []Indicator
- type IndicatorAttr
- type IndicatorClass
- type IndicatorClassRemove
- type IndicatorContent
- type InputEvent
- type JSX
- type KeyboardEvent
- type Location
- type ParsedForm
- type PathMatcher
- type PointerEvent
- type QueryMatcher
- func QueryMatcherIfPresent(params ...string) QueryMatcher
- func QueryMatcherIgnoreAll() QueryMatcher
- func QueryMatcherIgnoreSome(params ...string) QueryMatcher
- func QueryMatcherOnlyIfPresent(params ...string) []QueryMatcher
- func QueryMatcherOnlyIgnoreAll() []QueryMatcher
- func QueryMatcherOnlyIgnoreSome(params ...string) []QueryMatcher
- func QueryMatcherOnlySome(params ...string) []QueryMatcher
- func QueryMatcherSome(params ...string) QueryMatcher
- type Request
- type RequestAfter
- type RequestChange
- type RequestEvent
- type RequestFocus
- type RequestForm
- type RequestHook
- type RequestInput
- type RequestKeyboard
- type RequestModel
- type RequestPointer
- type RequestRawForm
- type RequestRawHook
- type Resource
- type ResourceStatic
- type Response
- type Route
- type RouteDir
- type RouteFS
- type RouteFile
- type RouteResource
- type Router
- type Scope
- type ScopeBlocking
- type ScopeConcurrent
- type ScopeDebounce
- type ScopeFrame
- type ScopeLatest
- type ScopeSerial
- type ScopeSet
- type Selector
- type SessionCallback
- type Source
- type Store
- type SystemConf
- type Use
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DocsFS embed.FS
DocsFS is the embedded documentation tree for internal purposes.
Functions ¶
func Call ¶
func Call(ctx context.Context, action Action) context.CancelFunc
Call dispatches action to the client and returns a best-effort cancel function.
func Free ¶
Free returns a context that is safe to use with extended Doors operations that may wait for asynchronous completion, such as X-prefixed methods, and with long-running goroutines tied to the page runtime.
The returned context keeps the original Values from ctx, but uses the root Doors context for framework features such as beam reads/subscriptions and uses the instance runtime for cancellation, deadline, and lifetime.
func Go ¶
Go starts f when the surrounding component is rendered.
The passed context is canceled when the dynamic owner is unmounted, which makes Go a good fit for background loops that should stop with the page. The context is also equivalent to calling Free on the surrounding context, so it is safe to use with X* operations and other long-running runtime work.
Example:
@doors.Go(func(ctx context.Context) {
for {
select {
case <-time.After(time.Second):
door.Update(ctx, currentTime())
case <-ctx.Done():
return
}
}
})
func Inject ¶
Inject renders el with the latest beam value stored in the child context under key.
Example:
~>doors.Inject("user", userBeam) <section>
~{
user := ctx.Value("user").(User)
}
<span>~(user.Name)</span>
</section>
func InstanceEnd ¶
InstanceEnd ends the current instance (tab/window) but keeps the session and other instances active.
func InstanceId ¶
InstanceId returns the unique ID of the current instance. Useful for logging, debugging, and tracking connections.
func SessionEnd ¶
SessionEnd immediately ends the current session and all instances. Use it during logout to close authorized pages and free server resources.
func SessionExpire ¶
SessionExpire sets the maximum lifetime of the current session.
func SessionId ¶
SessionId returns the unique ID of the current session. All instances in the same browser share this ID via a session cookie.
func Status ¶
Status sets the initial HTTP status code for the current page render.
Example:
~(doors.Status(http.StatusNotFound))
func Sub ¶
Sub renders a dynamic fragment driven by beam.
It subscribes to beam and re-renders the inner content whenever the value changes. Returning nil from el clears the fragment.
Example:
elem demo(beam Beam[int]) {
~(doors.Sub(beam, elem(v int) {
<span>~(v)</span>
}))
}
func UseErrorPage ¶
UseErrorPage renders page when Doors hits an internal routing, instance, or rendering error.
func UseFallback ¶
UseFallback sends unmatched requests to handler.
This is useful when Doors is mounted inside a larger HTTP server.
func UseLicense ¶
UseLicense stores a license string on the managed Doors client script. When omitted, the client prints the AGPL notice. You can purchase suitable license at https://doors.dev or via email sales@doors.dev
func UseModel ¶
func UseModel[M any](r Router, handler func(r RequestModel, s Source[M]) Response)
UseModel registers a page model and its handler on r.
The model type M defines matching and URL generation through `path` and `query` struct tags. The handler receives the request metadata and the current route as a Source.
Example:
type BlogPath struct {
Home bool `path:"/"`
Post bool `path:"/posts/:ID"`
ID int
Tag *string `query:"tag"`
}
doors.UseModel(router, func(r doors.RequestModel, s doors.Source[BlogPath]) doors.Response {
return doors.ResponseComp(Page(s))
})
func UseServerID ¶
UseServerID sets the stable server identifier used in Doors-generated paths and cookies.
id must already be URL-safe.
func UseSessionCallback ¶
func UseSessionCallback(r Router, callback SessionCallback)
UseSessionCallback registers session lifecycle callbacks on r.
func UseSystemConf ¶
func UseSystemConf(r Router, conf SystemConf)
UseSystemConf applies conf to r after filling in Doors defaults.
func XCall ¶
func XCall[T any](ctx context.Context, action Action) (<-chan CallResult[T], context.CancelFunc)
XCall dispatches action to the client and returns a result channel.
The channel closes without a value if the call is canceled. Do not wait on it during rendering. If you need to wait, do it in a hook, inside Go, or in your own goroutine with Free. T is the expected decoded payload type. For actions other than ActionEmit, json.RawMessage is usually the right choice.
Types ¶
type ABlur ¶
type ABlur struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError []Action
}
ABlur prepares a blur event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AChange ¶
type AChange struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[ChangeEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestChange) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AChange handles the browser `change` event.
Use it for committed values such as blur-triggered input changes or select changes.
type AClick ¶
type AClick struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AClick prepares a click event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type AData ¶
type AData struct {
// Name of the data entry to read via JavaScript with $data(name).
// Required.
Name string
// Value to expose to the client. Marshaled to JSON.
// Required.
Value any
}
AData exposes Value to browser code through `$data(name)`.
`$data(...)` returns strings and JSON-backed values directly. For `[]byte`, it returns a promise that resolves to an `ArrayBuffer`.
type AFocus ¶
type AFocus struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AFocus prepares a focus event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AFocusIn ¶
type AFocusIn struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AFocusIn prepares a focusin event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AFocusOut ¶
type AFocusOut struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[FocusEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestFocus) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AFocusOut prepares a focusout event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AGotPointerCapture ¶
type AGotPointerCapture struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
AGotPointerCapture prepares a gotpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AHook ¶
type AHook[T any] struct { // Name of the hook to call from JavaScript via $hook(name, ...). // Required. Name string // Defines how the hook is scheduled (e.g. blocking, debounce). // Optional. Scope []Scope // Visual indicators while the hook is running. // Optional. Indicator []Indicator // Backend handler for the hook. // Receives typed input (T, unmarshaled from JSON) through RHook, // and returns any output which will be marshaled to JSON. // Should return true when the hook is complete and can be removed. // Required. On func(ctx context.Context, r RequestHook[T]) (any, bool) }
AHook exposes a named Go handler to the browser through `$hook(name, ...)`.
Input data is unmarshaled from JSON into type T. The returned value is encoded back to JSON.
type AInput ¶
type AInput struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[InputEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestInput) bool
// If true, does not include value in event
// Optional.
ExcludeValue bool
// Actions to run on error.
// Optional.
OnError []Action
}
AInput handles the browser `input` event.
Use it for live updates while the user is still editing a value.
type AKeyDown ¶
type AKeyDown struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Filters by event.key if provided.
// Optional.
Filter []string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Backend event handler.
// Receives a typed REvent[KeyboardEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestKeyboard) bool
// Actions to run on error.
// Optional.
OnError []Action
// Actions to run before the hook request.
// Optional.
Before []Action
}
AKeyDown prepares a key down event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type AKeyUp ¶
type AKeyUp struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Filters by event.key if provided.
// Optional.
Filter []string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Backend event handler.
// Receives a typed REvent[KeyboardEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestKeyboard) bool
// Actions to run on error.
// Optional.
OnError []Action
// Actions to run before the hook request.
// Optional.
Before []Action
}
AKeyUp prepares a key up event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type ALink ¶
type ALink struct {
// Target path model value. Required.
Model any
// Fragment identifier
// Optional
Fragment string
// Active link indicator configuration. Optional.
Active Active
// Stop event propagation (for dynamic links). Optional.
StopPropagation bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running
// (for dynamic links). Optional.
Indicator []Indicator
// Actions to run before the hook request (for dynamic links). Optional.
Before []Action
// Actions to run after the hook request (for dynamic links). Optional.
After []Action
// Actions to run on error (for dynamic links).
// Default (nil) triggers a location reload.
OnError []Action
}
ALink builds a real `href` from Model and, when possible, upgrades the link to same-model client navigation.
Example:
attrs := doors.A(ctx, doors.ALink{
Model: Path{Home: true},
})
type ALostPointerCapture ¶
type ALostPointerCapture struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
ALostPointerCapture prepares a lostpointercapture event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerCancel ¶
type APointerCancel struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerCancel prepares a pointer cancel event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerDown ¶
type APointerDown struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerDown prepares a pointer down event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type APointerEnter ¶
type APointerEnter struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerEnter prepares a pointer enter event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerLeave ¶
type APointerLeave struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerLeave prepares a pointer leave event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerMove ¶
type APointerMove struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerMove prepares a pointer move event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type APointerOut ¶
type APointerOut struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerOut prepares a pointer out event hook for DOM elements, with configurable propagation, scheduling, indicators, and handlers.
type APointerOver ¶
type APointerOver struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerOver prepares a pointer over event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type APointerUp ¶
type APointerUp struct {
// If true, stops the event from bubbling up the DOM.
// Optional.
StopPropagation bool
// If true, prevents the browser's default action for the event.
// Optional.
PreventDefault bool
// If true, only fires when the event occurs on this element itself.
// Optional.
ExactTarget bool
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend event handler.
// Receives a typed REvent[PointerEvent].
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestPointer) bool
// Actions to run on error.
// Optional.
OnError []Action
}
APointerUp prepares a pointer up event hook for DOM elements, configuring propagation, scheduling, indicators, and handlers.
type ARawHook ¶
type ARawHook struct {
// Name of the hook to call from JavaScript via $hook(name, ...).
// Required.
Name string
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Backend handler for the hook.
// Provides raw access via RRawHook (body reader, multipart parser).
// Should return true when the hook is complete and can be removed.
// Required.
On func(ctx context.Context, r RequestRawHook) bool
}
ARawHook exposes a named Go handler to the browser through `$hook(name, ...)` without JSON decoding or encoding.
Use it for streaming, custom protocols, or file uploads.
type ARawSubmit ¶
type ARawSubmit struct {
// Defines how the hook is scheduled (e.g. blocking, debounce).
// Optional.
Scope []Scope
// Visual indicators while the hook is running.
// Optional.
Indicator []Indicator
// Actions to run before the hook request.
// Optional.
Before []Action
// Backend form handler.
// Should return true when the hook is complete and can be removed.
// Required.
On func(context.Context, RequestRawForm) bool
// Actions to run on error.
// Optional.
OnError []Action
}
ARawSubmit handles a form submission with raw multipart access.
type AShared ¶
type AShared = *aShared
AShared is a reusable dynamic attribute handle shared across every element it is attached to.
func NewAShared ¶
NewAShared returns an enabled shared attribute handle.
Update, Enable, and Disable affect every attached element together.
type ASubmit ¶
type ASubmit[T any] struct { // MaxMemory sets the maximum number of bytes to parse into memory. // It is passed to ParseMultipartForm. // Defaults to 8 MB if zero. MaxMemory int // Defines how the hook is scheduled (e.g. blocking, debounce). // Optional. Scope []Scope // Visual indicators while the hook is running. // Optional. Indicator []Indicator // Actions to run before the hook request. // Optional. Before []Action // Backend form handler. // Should return true when the hook is complete and can be removed. // Required. On func(context.Context, RequestForm[T]) bool // Actions to run on error. // Optional. OnError []Action }
ASubmit handles a form submission by decoding it into T with go-playground/form.
type Action ¶
type Action interface {
// contains filtered or unexported methods
}
Action performs a client-side operation.
func ActionOnlyEmit ¶
ActionOnlyEmit returns a single ActionEmit.
func ActionOnlyIndicate ¶
ActionOnlyIndicate returns a single ActionIndicate.
func ActionOnlyLocationAssign ¶
ActionOnlyLocationAssign returns a single ActionLocationAssign.
func ActionOnlyLocationRawAssign ¶
ActionOnlyLocationRawAssign returns a single ActionLocationRawAssign.
func ActionOnlyLocationReload ¶
func ActionOnlyLocationReload() []Action
ActionOnlyLocationReload returns a single ActionLocationReload.
func ActionOnlyLocationReplace ¶
ActionOnlyLocationReplace returns a single ActionLocationReplace.
func ActionOnlyScroll ¶
ActionOnlyScroll returns a single ActionScroll with default scroll behavior.
type ActionEmit ¶
ActionEmit invokes a client-side handler registered with `$on(name, handler)`.
type ActionIndicate ¶
ActionIndicate applies indicators for Duration.
type ActionLocationAssign ¶
type ActionLocationAssign struct {
Model any
}
ActionLocationAssign navigates to a model-derived URL.
type ActionLocationRawAssign ¶
type ActionLocationRawAssign struct {
URL string
}
ActionLocationRawAssign navigates to url without first encoding a path model.
type ActionLocationReload ¶
type ActionLocationReload struct{}
ActionLocationReload reloads the current page.
type ActionLocationReplace ¶
type ActionLocationReplace struct {
Model any
}
ActionLocationReplace replaces the current history entry with a model-derived URL.
type ActionScroll ¶
type ActionScroll struct {
// CSS selector for the element to scroll into view.
Selector string
// Browser scroll options forwarded to `scrollIntoView(...)`.
Options any
}
ActionScroll scrolls the first element matching Selector into view.
Options is passed to the browser scroll call as-is and should match the shape accepted by `Element.scrollIntoView(...)`, for example: `map[string]any{"behavior": "smooth", "block": "center"}`.
type Active ¶
type Active struct {
// Path match strategy
PathMatcher PathMatcher
// Query param match strategy, applied sequentially.
QueryMatcher []QueryMatcher
// Match fragment, false by default
FragmentMatch bool
// Indicators to apply when active
Indicator []Indicator
}
Active configures how ALink marks itself as active.
type Attr ¶
Attr is a Doors attribute modifier that can be attached directly to an element or applied through a proxy component.
type Beam ¶
Beam is a read-only reactive value.
Use a Beam to read, subscribe to, or derive a smaller view of state. During one render/update cycle, a Door subtree observes one consistent value for the same beam.
func NewBeam ¶
func NewBeam[T any, T2 comparable](source Beam[T], cast func(T) T2) Beam[T2]
NewBeam derives a Beam from source and uses `==` to suppress equal derived values.
Example:
fullName := doors.NewBeam(user, func(u User) string {
return u.FirstName + " " + u.LastName
})
func NewBeamEqual ¶
func NewBeamEqual[T any, T2 any](source Beam[T], cast func(T) T2, equal func(new T2, old T2) bool) Beam[T2]
NewBeamEqual derives a Beam from source with a custom equality function.
equal should report whether new and old should be treated as equal and therefore not propagated. If equal is nil, every derived value propagates.
type CallResult ¶
CallResult holds the outcome of an XCall. Either Ok is set with the result, or Err is non-nil.
type ChangeEvent ¶
type ChangeEvent = front.ChangeEvent
ChangeEvent is the payload sent to AChange handlers.
type Door ¶
Door is a dynamic placeholder in the DOM tree that can be updated, replaced, or removed after render.
Doors start inactive and become active when rendered. Operations on an inactive door are stored virtually and applied when the door becomes active. If a door is removed or replaced, it becomes inactive again, but operations continue to update that virtual state for future rendering.
The context used while rendering a door's content follows the door's lifecycle, which makes `ctx.Done()` safe to use in background goroutines that depend on the door staying mounted.
X-prefixed methods return a channel that reports completion. For inactive doors, that channel closes immediately without sending a value.
type ESConf ¶
type ESConf = resources.BuildProfiles
ESConf provides named esbuild profiles for script and style processing.
type FocusEvent ¶
type FocusEvent = front.FocusEvent
FocusEvent is the payload sent to focus event handlers.
type HrefActiveMatch ¶
type HrefActiveMatch int
HrefActiveMatch describes a path matching strategy for active links.
const ( // MatchFull requires the entire path to match. MatchFull HrefActiveMatch = iota // MatchPath requires the same path but ignores the query. MatchPath // MatchStarts requires the current path to start with the target path. MatchStarts )
type Indicator ¶
Indicator is a temporary DOM change applied on the client.
Indicators are commonly used for pending states such as "Loading..." text, temporary classes, or transient attributes while a request is in flight.
func IndicatorOnlyAttr ¶
IndicatorOnlyAttr sets an attribute on the event target element.
func IndicatorOnlyAttrQuery ¶
IndicatorOnlyAttrQuery sets an attribute on the first element matching a CSS query.
func IndicatorOnlyAttrQueryAll ¶
IndicatorOnlyAttrQueryAll sets an attribute on all elements matching a CSS query.
func IndicatorOnlyAttrQueryParent ¶
IndicatorOnlyAttrQueryParent sets an attribute on the closest ancestor matching a CSS query.
func IndicatorOnlyClass ¶
IndicatorOnlyClass adds classes to the event target element.
func IndicatorOnlyClassQuery ¶
IndicatorOnlyClassQuery adds classes to the first element matching a CSS query.
func IndicatorOnlyClassQueryAll ¶
IndicatorOnlyClassQueryAll adds classes to all elements matching a CSS query.
func IndicatorOnlyClassQueryParent ¶
IndicatorOnlyClassQueryParent adds classes to the closest ancestor matching a CSS query.
func IndicatorOnlyClassRemove ¶
IndicatorOnlyClassRemove removes classes from the event target element.
func IndicatorOnlyClassRemoveQuery ¶
IndicatorOnlyClassRemoveQuery removes classes from the first element matching a CSS query.
func IndicatorOnlyClassRemoveQueryAll ¶
IndicatorOnlyClassRemoveQueryAll removes classes from all elements matching a CSS query.
func IndicatorOnlyClassRemoveQueryParent ¶
IndicatorOnlyClassRemoveQueryParent removes classes from the closest ancestor matching a CSS query.
func IndicatorOnlyContent ¶
IndicatorOnlyContent sets content on the event target element.
func IndicatorOnlyContentQuery ¶
IndicatorOnlyContentQuery sets content on the first element matching a CSS query.
func IndicatorOnlyContentQueryAll ¶
IndicatorOnlyContentQueryAll sets content on all elements matching a CSS query.
func IndicatorOnlyContentQueryParent ¶
IndicatorOnlyContentQueryParent sets content on the closest ancestor matching a CSS query.
type IndicatorAttr ¶
type IndicatorAttr struct {
Selector Selector // Target element
Name string // Attribute name
Value string // Attribute value
}
IndicatorAttr temporarily sets an attribute on the selected element.
func (IndicatorAttr) Indicate ¶
func (c IndicatorAttr) Indicate() indicate
type IndicatorClass ¶
type IndicatorClass struct {
Selector Selector // Target element
Class string // Space-separated classes
}
IndicatorClass temporarily adds CSS classes to the selected element.
func (IndicatorClass) Indicate ¶
func (c IndicatorClass) Indicate() indicate
type IndicatorClassRemove ¶
type IndicatorClassRemove struct {
Selector Selector // Target element
Class string // Space-separated classes
}
IndicatorClassRemove temporarily removes CSS classes from the selected element.
func (IndicatorClassRemove) Indicate ¶
func (c IndicatorClassRemove) Indicate() indicate
type IndicatorContent ¶
type IndicatorContent struct {
Selector Selector // Target element
Content string // Replacement content
}
IndicatorContent temporarily replaces the selected element's inner HTML.
func (IndicatorContent) Indicate ¶
func (c IndicatorContent) Indicate() indicate
type InputEvent ¶
type InputEvent = front.InputEvent
InputEvent is the payload sent to AInput handlers.
type JSX ¶
type JSX struct {
JSX api.JSX
Factory string
ImportSource string
Fragment string
SideEffects bool
Dev bool
}
JSX configures how esbuild should transform JSX input.
type KeyboardEvent ¶
type KeyboardEvent = front.KeyboardEvent
KeyboardEvent is the payload sent to keyboard event handlers.
type Location ¶
Location is a parsed or generated URL path plus query string.
Example ¶
loc := Location{
Segments: []string{"posts", "42"},
Query: url.Values{
"tag": []string{"go"},
"page": []string{"2"},
},
}
fmt.Println(loc.String())
Output: /posts/42?page=2&tag=go
type ParsedForm ¶
type ParsedForm interface {
// FormValues returns all parsed form values.
FormValues() url.Values
// FormValue returns the first value for the given key.
FormValue(key string) string
// FormFile returns the uploaded file for the given key.
FormFile(key string) (multipart.File, *multipart.FileHeader, error)
// Form returns the underlying multipart.Form.
Form() *multipart.Form
}
ParsedForm exposes parsed multipart form values and files.
type PathMatcher ¶
type PathMatcher interface {
// contains filtered or unexported methods
}
PathMatcher customizes how the path participates in active-link matching.
func PathMatcherFull ¶
func PathMatcherFull() PathMatcher
PathMatcherFull matches the full generated path.
func PathMatcherSegments ¶
func PathMatcherSegments(i ...int) PathMatcher
PathMatcherSegments matches only the listed path segment indexes (zero-based).
func PathMatcherStarts ¶
func PathMatcherStarts() PathMatcher
PathMatcherStarts matches when the current path starts with the link path.
type PointerEvent ¶
type PointerEvent = front.PointerEvent
PointerEvent is the payload sent to pointer event handlers.
type QueryMatcher ¶
type QueryMatcher interface {
// contains filtered or unexported methods
}
QueryMatcher customizes how query parameters participate in active-link matching.
func QueryMatcherIfPresent ¶
func QueryMatcherIfPresent(params ...string) QueryMatcher
QueryMatcherIfPresent matches the given parameters only if they are present.
func QueryMatcherIgnoreAll ¶
func QueryMatcherIgnoreAll() QueryMatcher
QueryMatcherIgnoreAll excludes all remaining query parameters from comparison.
func QueryMatcherIgnoreSome ¶
func QueryMatcherIgnoreSome(params ...string) QueryMatcher
QueryMatcherIgnoreSome excludes the given query parameters from comparison.
func QueryMatcherOnlyIfPresent ¶
func QueryMatcherOnlyIfPresent(params ...string) []QueryMatcher
QueryMatcherOnlyIfPresent matches the given parameters if present and ignores all others.
func QueryMatcherOnlyIgnoreAll ¶
func QueryMatcherOnlyIgnoreAll() []QueryMatcher
QueryMatcherOnlyIgnoreAll ignores all query parameters.
func QueryMatcherOnlyIgnoreSome ¶
func QueryMatcherOnlyIgnoreSome(params ...string) []QueryMatcher
QueryMatcherOnlyIgnoreSome ignores the given parameters and matches all remaining.
func QueryMatcherOnlySome ¶
func QueryMatcherOnlySome(params ...string) []QueryMatcher
QueryMatcherOnlySome matches the provided query parameters and ignores all others.
func QueryMatcherSome ¶
func QueryMatcherSome(params ...string) QueryMatcher
QueryMatcherSome matches only the provided query parameters.
type Request ¶
type Request interface {
// SetCookie adds a cookie to the response.
SetCookie(cookie *http.Cookie)
// GetCookie retrieves a cookie by name.
GetCookie(name string) (*http.Cookie, error)
}
Request exposes the common server-side request helpers available to Doors handlers.
type RequestAfter ¶
type RequestAfter interface {
// After appends client-side actions to the successful response.
After([]Action) error
}
RequestAfter schedules client-side actions to run after a successful request.
type RequestChange ¶
type RequestChange = RequestEvent[ChangeEvent]
RequestChange is the typed request passed to AChange handlers.
type RequestEvent ¶
type RequestEvent[E any] interface { Request RequestAfter // Event returns the event payload. Event() E }
RequestEvent is the request context passed to event handlers.
type RequestFocus ¶
type RequestFocus = RequestEvent[FocusEvent]
RequestFocus is the typed request passed to focus event handlers.
type RequestForm ¶
type RequestForm[D any] interface { Request RequestAfter // Data returns the parsed form payload. Data() D }
RequestForm is the request context passed to decoded form handlers.
type RequestHook ¶
type RequestHook[D any] interface { Request RequestAfter // Data returns the parsed hook payload. Data() D }
RequestHook is the request context passed to typed JavaScript hook handlers.
type RequestInput ¶
type RequestInput = RequestEvent[InputEvent]
RequestInput is the typed request passed to AInput handlers.
type RequestKeyboard ¶
type RequestKeyboard = RequestEvent[KeyboardEvent]
RequestKeyboard is the typed request passed to keyboard event handlers.
type RequestModel ¶
type RequestModel interface {
Request
// SessionStore returns session-scoped storage.
SessionStore() Store
// RequestHeader returns the incoming request headers.
RequestHeader() http.Header
// ResponseHeader returns the outgoing response headers.
ResponseHeader() http.Header
}
RequestModel is the request context passed to UseModel handlers.
Use it for cookies, request and response headers, and session-scoped state while deciding which Response to return.
type RequestPointer ¶
type RequestPointer = RequestEvent[PointerEvent]
RequestPointer is the typed request passed to pointer event handlers.
type RequestRawForm ¶
type RequestRawForm interface {
Request
RequestAfter
// W returns the HTTP response writer.
W() http.ResponseWriter
// Reader returns a multipart reader for streaming form parts.
Reader() (*multipart.Reader, error)
// ParseForm parses the form data with a memory limit.
ParseForm(maxMemory int) (ParsedForm, error)
}
RequestRawForm is the request context passed to raw multipart form handlers.
type RequestRawHook ¶
type RequestRawHook interface {
RequestRawForm
// Body returns the raw request body reader.
Body() io.ReadCloser
}
RequestRawHook is the request context passed to raw JavaScript hook handlers.
type Resource ¶
Resource describes content or a URL that can be attached to HTML resource attributes and, when needed, hosted by Doors.
func ResourceExternal ¶
ResourceExternal points at an already-hosted URL.
func ResourceHandler ¶
func ResourceHandler(handler func(w http.ResponseWriter, r *http.Request)) Resource
ResourceHandler serves content through a standard library-style handler.
func ResourceHook ¶
func ResourceHook(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request) bool) Resource
ResourceHook serves content through a custom handler.
Returning true tells Doors it may remove the generated private resource after the request.
func ResourceProxy ¶
ResourceProxy reverse-proxies requests to url.
type ResourceStatic ¶
type ResourceStatic = printer.SourceStatic
ResourceStatic is a Resource that can also be mounted at a stable public path with RouteResource.
func ResourceBytes ¶
func ResourceBytes(content []byte) ResourceStatic
ResourceBytes serves content from content.
func ResourceFS ¶
func ResourceFS(fsys fs.FS, entry string) ResourceStatic
ResourceFS serves one file from fsys.
func ResourceLocalFS ¶
func ResourceLocalFS(path string) ResourceStatic
ResourceLocalFS serves one local file from path.
func ResourceString ¶
func ResourceString(content string) ResourceStatic
ResourceString serves content from content.
type Response ¶
Response describes how a matched page model should be handled.
Use ResponseComp to render a page, ResponseRedirect to send an HTTP redirect, or ResponseReroute to hand the request to another registered model without redirecting the browser.
func ResponseComp ¶
ResponseComp returns a Response that renders comp for the matched model.
func ResponseRedirect ¶
ResponseRedirect returns a Response that redirects to model.
status may be 0 to let Doors choose its default redirect status.
func ResponseReroute ¶
ResponseReroute returns a Response that resolves another registered model on the server without changing the current HTTP response into a redirect.
type Route ¶
Route handles a non-page GET endpoint inside a Router.
Use UseRoute for endpoints such as health checks, stable file mounts, or other GET handlers that should live beside model-based pages.
type RouteDir ¶
type RouteDir struct {
// URL prefix under which files are served.
// Required.
Prefix string
// Filesystem directory path to serve.
// Required.
DirPath string
// Cache-Control header applied to responses.
// Optional.
CacheControl string
}
RouteDir serves files from a local directory under Prefix.
type RouteFS ¶
type RouteFS struct {
// URL prefix under which files are served.
// Required.
Prefix string
// Filesystem to serve files from.
// Required.
FS fs.FS
// Optional Cache-Control header applied to responses.
// Optional.
CacheControl string
}
RouteFS serves files from an fs.FS under Prefix.
type RouteFile ¶
type RouteFile struct {
// URL path at which the file is served.
// Required.
Path string
// Filesystem path to the file to serve.
// Reuired.
FilePath string
// Cache-Control header applied to the response.
// Optional.
CacheControl string
}
RouteFile serves one local file at Path.
type RouteResource ¶
type RouteResource struct {
// URL path at which the file is served.
// Required.
Path string
Resource ResourceStatic
// ContentType header
ContentType string
}
RouteResource serves one static ResourceStatic at a fixed public path.
Use it when you want a stable URL but still want Doors to prepare the resource through its registry.
func (RouteResource) Serve ¶
func (rt RouteResource) Serve(w http.ResponseWriter, r *http.Request)
type Router ¶
type Router interface {
http.Handler
// Count returns the current number of live sessions and live page
// instances.
Count() (sessions int, instances int)
Use(r Use)
}
Router serves a Doors application over HTTP.
Use NewRouter to create one, register page models with UseModel, and then pass it to an HTTP server.
func NewRouter ¶
func NewRouter() Router
NewRouter returns a router with the default Doors configuration.
Example:
router := doors.NewRouter()
doors.UseModel(router, func(r doors.RequestModel, s doors.Source[Path]) doors.Response {
return doors.ResponseComp(Page(s))
})
Example ¶
router := NewRouter()
UseModel(router, func(r RequestModel, s Source[examplePath]) Response {
return ResponseRedirect(examplePath{Post: true, ID: 42}, http.StatusFound)
})
type Scope ¶
Scope controls how overlapping client-side events coordinate before the backend request starts.
func ScopeOnlyBlocking ¶
func ScopeOnlyBlocking() []Scope
ScopeOnlyBlocking returns a single ScopeBlocking.
func ScopeOnlyDebounce ¶
ScopeOnlyDebounce returns one debounced Scope.
type ScopeBlocking ¶
type ScopeBlocking struct {
// contains filtered or unexported fields
}
ScopeBlocking rejects a new event while another event in the same shared scope is still running.
type ScopeConcurrent ¶
type ScopeConcurrent struct {
// contains filtered or unexported fields
}
ScopeConcurrent allows overlap only for events that use the same group id.
type ScopeDebounce ¶
type ScopeDebounce struct {
// contains filtered or unexported fields
}
ScopeDebounce delays a burst of events and keeps the latest pending one.
type ScopeFrame ¶
type ScopeFrame struct {
// contains filtered or unexported fields
}
ScopeFrame coordinates normal events with a barrier event.
Normal members use Scope(false). The barrier member uses Scope(true), waits for earlier members to finish, and then runs exclusively.
func (*ScopeFrame) Scope ¶
func (d *ScopeFrame) Scope(frame bool) Scope
Scope returns a frame member or a frame barrier depending on frame.
type ScopeLatest ¶
type ScopeLatest struct {
// contains filtered or unexported fields
}
ScopeLatest keeps only the newest event in a shared scope. When a new event arrives, any currently processing event is canceled and the new event takes priority.
type ScopeSerial ¶
type ScopeSerial struct {
// contains filtered or unexported fields
}
ScopeSerial queues accepted events and runs them in arrival order.
type Selector ¶
type Selector interface {
// contains filtered or unexported methods
}
Selector chooses which DOM nodes an Indicator should target.
func SelectorQuery ¶
SelectorQuery selects the first element matching query.
func SelectorQueryAll ¶
SelectorQueryAll selects every element matching query.
func SelectorQueryParent ¶
SelectorQueryParent selects the closest ancestor matching query.
func SelectorTarget ¶
func SelectorTarget() Selector
SelectorTarget selects the element that triggered the event.
type SessionCallback ¶
type SessionCallback = router.SessionCallback
SessionCallback observes session creation and removal.
type Source ¶
Source is a writable Beam.
Create a source with NewSource or NewSourceEqual, then derive smaller beams with NewBeam or NewBeamEqual. For reference types such as slices, maps, pointers, or mutable structs, replace the stored value instead of mutating it in place.
func NewSource ¶
func NewSource[T comparable](init T) Source[T]
NewSource creates a Source that uses `==` to suppress equal updates.
Example:
count := doors.NewSource(0)
Example ¶
count := NewSource(1)
label := NewBeam(count, func(v int) string {
return fmt.Sprintf("count:%d", v)
})
fmt.Println(count.Get())
_ = label
Output: 1
func NewSourceEqual ¶
NewSourceEqual creates a Source with a custom equality function.
equal should report whether new and old should be treated as equal and therefore not propagated. If equal is nil, every update propagates.
type Store ¶
Store is goroutine-safe key-value storage used for session and instance state.
func InstanceStore ¶
InstanceStore returns storage scoped to the current instance only.
func SessionStore ¶
SessionStore returns storage shared by all instances in the current session.
type SystemConf ¶
type SystemConf = common.SystemConf
SystemConf configures router, instance, and transport behavior.