Documentation
¶
Overview ¶
Package watch is the watch plugin of MyGo: it lets pages watch for changes to the files and directories the app names (see @caelyreth/evil-mygo-watch). Go code and native UI call mygo.WatchFiles directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Plugin = New(Options{})
Plugin is the plugin without roots, which lets pages watch nothing.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Roots are the directories and files pages may watch, by the names
// they use: lowercase letters, digits and dashes, starting with a
// letter.
Roots map[string]Root
// Resolve, when set, is asked for the root of a name that is not in
// Roots, with the call's context, so that the app can grant roots
// while it runs, such as a folder the user chose in a dialog. It
// returns false for names it doesn't know.
Resolve func(ctx context.Context, name string) (Root, bool)
// Allow, when set, is asked before each watch with the call's context
// and the request, and can refuse it.
Allow func(ctx context.Context, r Request) bool
// MaxWatchesPerPage is how many watches a page may have at a time: 8
// when zero.
MaxWatchesPerPage int
// MaxWatches is how many watches all pages may have at a time: 128
// when zero.
MaxWatches int
}
Options configures the plugin.
type Request ¶
type Request struct {
// Root is the name of the root.
Root string
// Path is what to watch in the root, relative to it and separated by
// slashes: "." for the root itself.
Path string
// Recursive asks to watch the directories in it too.
Recursive bool
}
Request is a watch a page asks for.
type Root ¶
type Root struct {
// Path is the absolute path of the directory or file.
Path string
// Recursive lets pages watch the directories in it too, and what is
// in them.
Recursive bool
// Ignore, when set, is asked about every file and directory a watch
// of the root finds, by its path relative to the root, separated by
// slashes, as mygo.FileWatchOptions.Ignore is.
Ignore func(path string, isDir bool) bool
}
Root is a directory, or a file, pages may watch.