Documentation ¶
Overview ¶
Package moria contains idiomatic Go data types and helper functions for defining Mithril components within Go.
Index ¶
- func BoolProp(target *bool) (getterSetter *js.Object)
- func Mount(root dom.Node, component Component)
- func Render(root dom.Node, cell View, force bool)
- func Route(root dom.Node, initial string, routes map[string]Component)
- func StringProp(target *string) (getterSetter *js.Object)
- func Version() string
- type Component
- type Controller
- type F
- type Prop
- type RequestOptions
- type RequestPromise
- type S
- type View
- type VirtualElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mount ¶
Mount takes a Component, converts (or creates) the appropriate mithril representation, and then calls it.
func Route ¶
Route takes a mapping of routes to components, creates the appropriate mithril representation, and then calls it.
func StringProp ¶
Types ¶
type Component ¶
type Component interface { Controller() Controller View(Controller) View }
Component is a reusable Mithril component.
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 ¶
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 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.
Click to show internal directories.
Click to hide internal directories.