Documentation
¶
Overview ¶
Package loader provides primitives to load an applet both when the underlying file changes and on demand when an update is requested.
Index ¶
- func RenderApplet(path string, config map[string]string, ...) ([]byte, []string, error)
- type ImageFormat
- type Loader
- func (l *Loader) CallSchemaHandler(ctx context.Context, config map[string]string, handlerName, parameter string) (string, error)
- func (l *Loader) Close() error
- func (l *Loader) GetSchema() []byte
- func (l *Loader) Height() int
- func (l *Loader) LoadApplet(config map[string]string) (string, error)
- func (l *Loader) Run() error
- func (l *Loader) Width() int
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderApplet ¶
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is a structure to provide applet loading when a file changes or on demand.
func NewLoader ¶
func NewLoader( id string, root *os.Root, watch bool, fileChanges chan bool, updatesChan chan Update, width, height, maxDuration int, timeout int, imageFormat ImageFormat, configOutFile string, output2x bool, ) (*Loader, error)
NewLoader instantiates a new loader structure. The loader will read off of fileChanges channel and write updates to the updatesChan. Updates are base64 encoded WebP strings. If watch is enabled, both file changes and on demand requests will send updates over the updatesChan.
func (*Loader) CallSchemaHandler ¶
func (*Loader) LoadApplet ¶
LoadApplet loads the applet on demand.
TODO: This method is thread safe, but has a pretty glaring race condition. If two callers request an update at the same time, they have the potential to get each others update. At the time of writing, this method is only called when you refresh a webpage during app development - so it doesn't seem likely that it's going to cause issues in the short term.