electron

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OctantCmdPreferences is a command for showing preferences
	OctantCmdPreferences = "octant.cmd.preferences"
)

Variables

This section is empty.

Functions

func SendMessage

func SendMessage(ctx context.Context, w *astilectron.Window, name string, payload interface{}, cs ...CallbackMessage)

SendMessage sends a message

Types

type AssetDirFunc

type AssetDirFunc func(name string) ([]string, error)

AssetDirFunc returns the files in an asset directory.

type AssetFunc

type AssetFunc func(name string) ([]byte, error)

AssetFunc loads an asset as bytes.

type CallbackMessage

type CallbackMessage func(m *MessageIn)

CallbackMessage represents a bootstrap message callback

type DefaultMessageListener

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

DefaultMessageListener listens for messages.

func NewMessageListener

func NewMessageListener() *DefaultMessageListener

NewMessageListener creates an instance of DefaultMessageListener.

func (*DefaultMessageListener) Handle

func (m *DefaultMessageListener) Handle(ctx context.Context, _ *astilectron.Window, message MessageIn) (interface{}, error)

Handle handles a message.

func (*DefaultMessageListener) Register

func (m *DefaultMessageListener) Register(handlers ...MessageHandler)

Register registers a handler.

func (*DefaultMessageListener) Unregister

func (m *DefaultMessageListener) Unregister(key string)

Unregister unregisters a listener key.

type Electron

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

Electron manages the electron app.

func New

func New(ctx context.Context, options Options) (*Electron, error)

New creates an instance of Electron.

func (*Electron) Start

func (e *Electron) Start(ctx context.Context, appURL string) error

Start starts the electron app.

func (*Electron) Stop

func (e *Electron) Stop()

Stop stops the electron app.

func (*Electron) Wait

func (e *Electron) Wait()

Wait waits for the electron app to stop.

type MessageHandler

type MessageHandler interface {
	// Key is the key for this handler.
	Key() string
	// Handle processes the message.
	Handle(ctx context.Context, in json.RawMessage) (interface{}, error)
}

MessageHandler handles a message.

type MessageIn

type MessageIn struct {
	Name    string          `json:"name"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

MessageIn is an incoming message.

type MessageListener

type MessageListener interface {
	// Handle handles a message using one of the registered message handlers.
	Handle(ctx context.Context, w *astilectron.Window, message MessageIn) (interface{}, error)
	// Register registers a message handler.
	Register(handlers ...MessageHandler)
	// Unregister unregisters a message handler by key.
	Unregister(key string)
}

MessageListener listens for messages.

type MessageOut

type MessageOut struct {
	Name    string      `json:"name"`
	Payload interface{} `json:"payload,omitempty"`
}

MessageOut is an outgoing message.

func CreateMessageOut

func CreateMessageOut(name string, payload interface{}) *MessageOut

CreateMessageOut creates an outgoing message.

type Options

type Options struct {
	// AppName is the name of the application.
	AppName string
	// Asset is asset loader.
	Asset AssetFunc
	// AssetDir is the asset directory lister.
	AssetDir AssetDirFunc
	// RestoreAssets is the asset restorer.
	RestoreAssets RestoreAssetsFunc
	// VersionAstilectron is the astilectron version.
	VersionAstilectron string
	// VersionElectron is the electron version.
	VersionElectron string
}

Options are options for configuring the electron app.

type PreferencesUpdatedHandler

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

PreferencesUpdatedHandler is a handler for updated preferences.

func NewPreferencesUpdatedHandler

func NewPreferencesUpdatedHandler(config PreferencesUpdatedHandlerConfig) *PreferencesUpdatedHandler

NewPreferencesUpdatedHandler creates an instances of PreferencesUpdatedHandler.

func (PreferencesUpdatedHandler) Handle

func (p PreferencesUpdatedHandler) Handle(ctx context.Context, in json.RawMessage) (interface{}, error)

Handle handles an update request.

func (PreferencesUpdatedHandler) Key

Key returns the key for this handler.

type PreferencesUpdatedHandlerConfig

type PreferencesUpdatedHandlerConfig interface {
	DataDirectory() string
}

PreferencesUpdatedHandlerConfig is configuration for PreferencesUpdatedHandler.

type RestoreAssetsFunc

type RestoreAssetsFunc func(dir string, name string) error

RestoreAssetsFunc restores assets.

Directories

Path Synopsis
preferences

Jump to

Keyboard shortcuts

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