updater

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package updater provides the ability for concurrently running demo pieces to update a shared json object.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SetFunc

type SetFunc func(v interface{})

SetFunc serializes the value passed in into json and sets the associated field to that value. If nil is passed (BUT NOT a nil value of an interface), the field will be removed from the Updater's json object.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater is like a json object, with each field allowed to be updated concurrently by a different process. After processing updates, Updater will call a provided method with the json serialized value of all of its fields.

func New

func New(ctx context.Context, set func([]byte)) *Updater

New creates an Updater. Set is called when fields update, using the json serialized value of Updater's tree. All updates after ctx is canceled are ignored.

func NewNested

func NewNested(ctx context.Context, set SetFunc) *Updater

NewNested creates an updater based on a field in another updater. This allows for grouping of related demo pieces into a single conceptual group.

func (*Updater) ForField

func (u *Updater) ForField(field string) SetFunc

ForField returns a function to set the latest value of that demo piece.

Jump to

Keyboard shortcuts

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