kirax

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: Apache-2.0 Imports: 9 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Kirax

A very opianated/experimental state management for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(target interface{}) (reflect.Value, error)

Clone a value

Types

type Action

type Action struct {
	Name    string
	Payload interface{}
}

Action to be dispatched

type Listener

type Listener chan SnapShot

Listener channel to SnapShot changes

type SnapShot

type SnapShot struct {
	When  time.Time
	Data  interface{}
	Error error
}

SnapShot snapshots of values

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store main struct

func NewStore

func NewStore(initState interface{}) *Store

NewStore creates a new store based on a state

func (*Store) AddListener

func (s *Store) AddListener(path string) <-chan SnapShot

AddListener returns a channel to changes according to a path

func (*Store) AddModifier

func (s *Store) AddModifier(action string, modifier interface{}) error

AddModifier adds a func that modifies the state, according to a Action name

func (*Store) Dispatch

func (s *Store) Dispatch(action Action) error

Dispatch actions to modify the state

func (*Store) GetState

func (s *Store) GetState() (interface{}, error)

GetState get copy of the current state

func (*Store) GetStateByPath

func (s *Store) GetStateByPath(path string) (interface{}, error)

GetStateByPath get copies of the current state according to a path

func (*Store) Patch added in v0.0.5

func (s *Store) Patch(path string, payload interface{}) error

Patch state according to a path

func (*Store) RemoveListener

func (s *Store) RemoveListener(path string) error

RemoveListener removes and close the listener channel

Directories

Path Synopsis
example module

Jump to

Keyboard shortcuts

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