Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Stores are all Vuex stores that the Go ecosystem knows about. All actions // that are defined for each store have to be registered in the JS Vuex store // under the same name and be redirected to the Go implementation using the // `CohorseVuexDispatch` JS function. // TODO: Add generator which creates the JS stubs for the actions. Stores = StoreIndex{ "global": NewStore(func() js.Value { return js.Global().Get("store") }, ActionIndex{ "setSysInfo": Action(func(s Store, payload interface{}) { s.Commit("setSysInfoVersion", sysinfo.Version) s.Commit("setSysInfoBuild", sysinfo.Build) s.Commit("setSysInfoCommit", sysinfo.Commit) s.Commit("finishAppLoading", nil) }), }), } )
Functions ¶
func ExposeDispatchActionFromJS ¶
func ExposeDispatchActionFromJS()
ExposeDispatchActionFromJS exposes the Action Dispatch function to the global JS namespace under the key `CohorseVuexDispatch`.
Types ¶
type Action ¶
type Action func(s Store, payload interface{})
Action is a Vuex action function that can be dispatched directly from Go or using the `CohorseVuexDispatch` function in JS.
type ActionIndex ¶
ActionIndex is the index of all known stores. Actions are scoped per store.
type ActionResponse ¶
type ActionResponse struct {
// contains filtered or unexported fields
}
ActionResponse is the structure in which the action response is encoded.
func (ActionResponse) JSValue ¶
func (resp ActionResponse) JSValue() js.Value
JSValue encodes the response of the action into a JS value which can be passed back to the JS frontend. Any non-nil error will be represented by a string of its message.
type ActionResponsePayload ¶
ActionResponsePayload has to be implemented by every payload that is returned by an action.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a Vuex store which can be used to dispatch actions or commit mutations. It stores the underlying JS object and all actions which are implemented in Go and can be dispatched using the `CohorseVuexDispatch` from JS.
func NewStore ¶
func NewStore(sf StoreObjectFunc, actions ActionIndex) Store
NewStore creates a new Store and uses the store object function to retrieve the JS object of the Vuex store.
type StoreObjectFunc ¶
StoreObjectFunc has to be supplied to the `NewStore` function. It has to return the JS object for the new Vuex store.