moria

package
v0.0.0-...-eea3727 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 3 Imported by: 6

Documentation

Overview

Package moria contains idiomatic Go data types and helper functions for defining Mithril components within Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolProp

func BoolProp(target *bool) (getterSetter *js.Object)

func Mount

func Mount(root dom.Node, component Component)

Mount takes a Component, converts (or creates) the appropriate mithril representation, and then calls it.

func Render

func Render(root dom.Node, cell View, force bool)

Render renders things

func Route

func Route(root dom.Node, initial string, routes map[string]Component)

Route takes a mapping of routes to components, creates the appropriate mithril representation, and then calls it.

func StringProp

func StringProp(target *string) (getterSetter *js.Object)

func Version

func Version() string

Version returns the version of the underlying Mithril library.

Types

type Component

type Component interface {
	Controller() Controller
	View(Controller) View
}

Component is a reusable Mithril component.

type Controller

type Controller interface {
}

Controller is an empty interface right now.

type F

type F func(*[]View)

func (F) View

func (f F) View() interface{}

type Prop

type Prop struct {
	*js.Object
}

type RequestOptions

type RequestOptions struct {
	Method          string                                                 // HTTP method to use (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS). Defaults to GET.
	URL             string                                                 // Path name to send the request to, optionally interpolated with values from Params.
	Params          js.M                                                   // Data to be interpolated into the URL and/or serialized into the query string.
	Body            js.M                                                   // Data to be serialized into the body (for other types of requests).
	Async           *bool                                                  // Whether the request should be asynchronous. Defaults to true.
	User            string                                                 // Username for HTTP authorization. Defaults to undefined.
	Password        string                                                 // Password for HTTP authorization. Defaults to undefined.
	WithCredentials bool                                                   // Whether to send cookies to 3rd party domains. Defaults to false.
	Timeout         int                                                    // Amount of milliseconds a request can take before automatically being terminated. Defaults to undefined.
	ResponseType    string                                                 // Expected type of the response. Defaults to "" if Extract is defined, "json" if missing.
	Config          func(xhr *js.Object) *js.Object                        // Exposes the underlying XMLHttpRequest object for low-level configuration and optional replacement (by returning a new XHR).
	Headers         map[string]string                                      // Headers to append to the request before sending it (applied right before Config).
	Type            func(any js.Object) js.Object                          // A constructor to be applied to each object in the response. Defaults to the identity function.
	Serialize       func(any js.Object) string                             // A serialization method to be applied to Body. Defaults to JSON.stringify, or if Body is an instance of FormData or URLSearchParams, defaults to the identity function (i.e. func(value js.Object) js.Object {return value}).
	Deserialize     func(any js.Object) js.Object                          // A deserialization method to be applied to the xhr.Response or normalized xhr.ResponseText. Defaults to the identity function. If Extract is defined, Deserialize will be skipped.
	Extract         func(xhr *js.Object, options RequestOptions) js.Object // A hook to specify how the XMLHttpRequest response should be read. Useful for processing response data, reading headers and cookies. By default this is a function that returns options.Deserialize(parsedResponse), throwing an exception when the server response status code indicates an error or when the response is syntactically invalid. If a custom Extract callback is provided, the xhr parameter is the XMLHttpRequest instance used for the request, and options is the object that was passed to the m.Request call. Additionally, Deserialize will be skipped and the value returned from the Extract callback will be left as-is when the promise resolves.
	Background      bool                                                   // If false, redraws mounted components upon completion of the request. If true, it does not. Defaults to false.
}

RequestOptions represents the options for an HTTP request made using the MithrilJS API.

type RequestPromise

type RequestPromise struct {
	*js.Object
}

func Request

func Request(ro RequestOptions) RequestPromise

func (RequestPromise) Then

func (r RequestPromise) Then(callable func(data *js.Object))

Then adds a callback function to be executed when the RequestPromise resolves.

type S

type S string

func (S) View

func (s S) View() interface{}

type View

type View interface {
	View() interface{}
}

A View is anything that can be rendered.

type VirtualElement

type VirtualElement struct {
	*js.Object
}

func M

func M(selector string, attrs js.M, children ...View) VirtualElement

func Trust

func Trust(trusted string) VirtualElement

func (VirtualElement) View

func (v VirtualElement) View() interface{}

VirtualElement implements interface View. However, there is a bug here.

Jump to

Keyboard shortcuts

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