vdomclient

package
v0.9.2-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefineComponent added in v0.9.2

func DefineComponent[P any](client *Client, name string, renderFn func(ctx context.Context, props P) any) vdom.Component[P]

func ServeFileOption added in v0.9.2

func ServeFileOption(w http.ResponseWriter, r *http.Request, option FileHandlerOption) error

ServeFileOption handles serving content based on the provided FileHandlerOption

Types

type AppOpts added in v0.9.2

type AppOpts struct {
	CloseOnCtrlC         bool
	GlobalKeyboardEvents bool
	GlobalStyles         []byte
	RootComponentName    string // defaults to "App"
	NewBlockFlag         string // defaults to "n" (set to "-" to disable)
	TargetNewBlock       bool
	TargetToolbar        *vdom.VDomTargetToolbar
}

type Client

type Client struct {
	Lock               *sync.Mutex
	AppOpts            AppOpts
	Root               *vdom.RootElem
	RootElem           *vdom.VDomElem
	RpcClient          *wshutil.WshRpc
	RpcContext         *wshrpc.RpcContext
	ServerImpl         *VDomServerImpl
	IsDone             bool
	RouteId            string
	VDomContextBlockId string
	DoneReason         string
	DoneCh             chan struct{}
	Opts               vdom.VDomBackendOpts
	GlobalEventHandler func(client *Client, event vdom.VDomEvent)
	GlobalStylesOption *FileHandlerOption
	UrlHandlerMux      *mux.Router
	OverrideUrlHandler http.Handler
	NewBlockFlag       bool
	SetupFn            func()
}

func MakeClient

func MakeClient(appOpts AppOpts) *Client

func (*Client) AddSetupFn added in v0.9.2

func (client *Client) AddSetupFn(fn func())

func (*Client) Connect added in v0.9.2

func (client *Client) Connect() error

func (*Client) CreateVDomContext

func (c *Client) CreateVDomContext(target *vdom.VDomTarget) error

func (*Client) GetAtomVal

func (c *Client) GetAtomVal(name string) any

func (*Client) GetIsDone

func (c *Client) GetIsDone() bool

func (*Client) RegisterComponent

func (c *Client) RegisterComponent(name string, cfunc any) error

func (*Client) RegisterDefaultFlags added in v0.9.2

func (client *Client) RegisterDefaultFlags()

func (*Client) RegisterFileHandler added in v0.9.2

func (c *Client) RegisterFileHandler(path string, option FileHandlerOption)

func (*Client) RegisterFilePrefixHandler added in v0.9.2

func (c *Client) RegisterFilePrefixHandler(prefix string, optionProvider func(path string) (*FileHandlerOption, error))

func (*Client) RegisterUrlPathHandler added in v0.9.2

func (c *Client) RegisterUrlPathHandler(path string, handler http.Handler)

func (*Client) RunMain added in v0.9.2

func (client *Client) RunMain()

func (*Client) SendAsyncInitiation

func (c *Client) SendAsyncInitiation() error

func (*Client) SetAtomVal

func (c *Client) SetAtomVal(name string, val any)

func (*Client) SetAtomVals

func (c *Client) SetAtomVals(m map[string]any)

func (*Client) SetGlobalEventHandler

func (c *Client) SetGlobalEventHandler(handler func(client *Client, event vdom.VDomEvent))

func (*Client) SetOverrideUrlHandler added in v0.9.2

func (c *Client) SetOverrideUrlHandler(handler http.Handler)

func (*Client) SetRootElem

func (c *Client) SetRootElem(elem *vdom.VDomElem)

type FileHandlerOption added in v0.9.2

type FileHandlerOption struct {
	FilePath string    // optional file path on disk
	Data     []byte    // optional byte slice content
	Reader   io.Reader // optional reader for content
	File     fs.File   // optional embedded or opened file
	MimeType string    // optional mime type
	ETag     string    // optional ETag (if set, resource may be cached)
}

type StreamingResponseWriter added in v0.9.2

type StreamingResponseWriter struct {
	// contains filtered or unexported fields
}

StreamingResponseWriter implements http.ResponseWriter interface to stream response data through a channel rather than buffering it in memory. This is particularly useful for handling large responses like video streams or file downloads.

func NewStreamingResponseWriter added in v0.9.2

func NewStreamingResponseWriter(respChan chan<- wshrpc.RespOrErrorUnion[wshrpc.VDomUrlRequestResponse]) *StreamingResponseWriter

func (*StreamingResponseWriter) Close added in v0.9.2

func (w *StreamingResponseWriter) Close() error

func (*StreamingResponseWriter) Header added in v0.9.2

func (w *StreamingResponseWriter) Header() http.Header

func (*StreamingResponseWriter) Write added in v0.9.2

func (w *StreamingResponseWriter) Write(data []byte) (int, error)

func (*StreamingResponseWriter) WriteHeader added in v0.9.2

func (w *StreamingResponseWriter) WriteHeader(statusCode int)

type VDomServerImpl

type VDomServerImpl struct {
	Client  *Client
	BlockId string
}

func (*VDomServerImpl) VDomRenderCommand

func (impl *VDomServerImpl) VDomRenderCommand(ctx context.Context, feUpdate vdom.VDomFrontendUpdate) chan wshrpc.RespOrErrorUnion[*vdom.VDomBackendUpdate]

func (*VDomServerImpl) VDomUrlRequestCommand added in v0.9.2

func (*VDomServerImpl) WshServerImpl

func (*VDomServerImpl) WshServerImpl()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL