Documentation
¶
Overview ¶
Package islands provides JavaScript integration for Vango components.
Deprecated: The v1 Developer Guide exposes islands via `el.JSIsland`. This package is retained for legacy/internal use only.
Islands allow embedding third-party JavaScript libraries or custom client-side logic while maintaining the component lifecycle and server communication.
Usage (v1 canonical):
Div(
JSIsland("my-chart", map[string]any{"data": [...] }),
)
By default the client loads `/js/islands/<id>.js` unless a `data-module` attribute is provided on the same element. Modules should export a mount(el, props, api) function that can optionally return {update, destroy, onMessage}.
Index ¶
- func DecodeIslandPayload[T any](msg vango.IslandMessage) (T, error)
- func IslandPlaceholder(children ...any) *vdom.VNode
- func JSIsland(id string, props any) []vdom.Attr
- func OnMessage(handler func(vango.IslandMessage)) vdom.Attr
- func OnMessageValidated(validate IslandMessageValidator, handler func(vango.IslandMessage)) vdom.Attr
- func SendToIsland(id string, payload any)
- func SendToIslandHID(hid string, payload any)
- func SetupOnIslandMessage[P any](s *vango.SetupCtx[P], id string, handler func(vango.IslandMessage))
- func SetupOnIslandMessageValidated[P any](s *vango.SetupCtx[P], id string, validate IslandMessageValidator, ...)
- type IslandMessageValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeIslandPayload ¶
func DecodeIslandPayload[T any](msg vango.IslandMessage) (T, error)
DecodeIslandPayload decodes an island message payload into a typed struct. This is useful for validation and to avoid relying on map[string]any.
Decoding is strict: unknown fields and trailing JSON values are rejected, matching vango.DecodeIslandPayload and IslandSchemaValidator behavior.
func IslandPlaceholder ¶
IslandPlaceholder renders a minimal SSR placeholder for island content. Use this inside the island container so the page is meaningful before JS mounts.
func JSIsland ¶
JSIsland marks an element as an island boundary. The island name identifies which client module should mount. For custom module paths, set a data-module attribute on the same element.
func OnMessage ¶ added in v0.0.2
func OnMessage(handler func(vango.IslandMessage)) vdom.Attr
OnMessage registers a per-instance handler for messages emitted by this island boundary.
This attaches the handler to the island element itself (keyed by HID), so multiple islands with the same name can coexist on a page without conflicting message routing.
func OnMessageValidated ¶ added in v0.2.0
func OnMessageValidated(validate IslandMessageValidator, handler func(vango.IslandMessage)) vdom.Attr
OnMessageValidated registers a per-instance handler with exact-sink validation metadata for this mounted island boundary.
func SendToIsland ¶
SendToIsland sends a message to the client-side island.
func SendToIslandHID ¶ added in v0.0.2
SendToIslandHID sends a message to a specific island instance (addressed by HID).
func SetupOnIslandMessage ¶
func SetupOnIslandMessage[P any](s *vango.SetupCtx[P], id string, handler func(vango.IslandMessage))
SetupOnIslandMessage registers a handler for messages from the island during Setup. This is the spec-aligned Setup-only variant.
func SetupOnIslandMessageValidated ¶
func SetupOnIslandMessageValidated[P any](s *vango.SetupCtx[P], id string, validate IslandMessageValidator, handler func(vango.IslandMessage))
SetupOnIslandMessageValidated registers a handler with validation for island messages. If validation fails, the handler is not invoked and the error is logged.
Types ¶
type IslandMessageValidator ¶
type IslandMessageValidator func(vango.IslandMessage) error
IslandMessageValidator validates an incoming island message.