app

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const APP_MODE = "prod"

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {

	// Config format version.
	Ver string `yaml:"guarki"`

	// App id must be unique!
	ID string `yaml:"id"`

	// App name.
	Name string `yaml:"name"`

	// App version.
	Version string `yaml:"version"`

	// App license.
	License string `yaml:"license"`

	// App log level.
	LogLevel string `yaml:"logLevel"`

	// App log.
	Log log.Logger

	// App embeds
	Embed *Embed

	Hooks Hooks

	Funcs Funcs

	// App plugins.
	Plugins Plugins

	EngineConfig map[string]interface{} `yaml:"engineConfig"`
	// contains filtered or unexported fields
}

App!

func (App) CacheFile

func (a App) CacheFile(name string) (string, error)

func (App) ConfigFile

func (a App) ConfigFile(name string) (string, error)

func (App) DataFile

func (a App) DataFile(name string) (string, error)

func (App) IsDev

func (a App) IsDev() bool

Check if app running in dev mode.

func (App) Path

func (a App) Path(elem ...string) string

Get file path from appdata dir.

func (App) Quit

func (a App) Quit()

func (*App) Run

func (a *App) Run() error

func (*App) Use

func (a *App) Use(engine Engine) error

type Context

type Context struct {
	App *App
	Params
}

Func context

func NewContext

func NewContext(a *App, params map[string]interface{}) Context

type Embed

type Embed struct {

	// List of embeds
	Files map[string]*[]byte
}

Embed struct

func (Embed) Data

func (e Embed) Data(name string) (b *[]byte, err error)

Get embeded data, it returns *[]byte and error

func (*Embed) Delete

func (e *Embed) Delete(name string)

Delete from embeds

func (Embed) UngzipData

func (e Embed) UngzipData(name string) ([]byte, error)

type Engine

type Engine interface {
	Init() error
	Run() error
	Bind(name string, fn Func) error
	Quit()
}

type Func

type Func func(Context) (interface{}, error)

Type of a Func to expose to JS api.

type Funcs

type Funcs map[string]Func

funcs to expose.

type Hook

type Hook func(*App) error

hook func.

type Hooks

type Hooks map[string]Hook

App hooks.

func (Hooks) Run

func (h Hooks) Run(n string, a *App) error

Run a hook.

type Params

type Params map[string]interface{}

JS call params

func (Params) Get

func (p Params) Get(key string) interface{}

Get value by key.

func (Params) GetOr

func (p Params) GetOr(key string, def interface{}) interface{}

Get if key exists, if not return default.

func (Params) Has

func (p Params) Has(key string) bool

Check params if has a key.

func (Params) Len

func (p Params) Len() int

Params len

type Plugin

type Plugin interface {

	// Init the plugin (called before starting the window).
	Init(App)

	// Get plugin name.
	GetName() string

	// Get plugin version.
	GetVersion() string

	// Get plugin exposed funcs to guarki js API.
	GetFuncs() map[string]Func
}

Guarki plugin interface.

type Plugins

type Plugins map[string]Plugin

App plugins.

Jump to

Keyboard shortcuts

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