model

package
v0.0.0-...-91df8d1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package model implements a global singleton data structure with functions for synchronized read+write access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mod

func Mod(mod func(*Model))

Mod provides synchronized read+write access to the Model data via argument to the given closure. The changed flag is unaffected by this method.

func Set

func Set(set func(*Model))

Set provides synchronized read+write access to the Model data via argument to the given closure. The changed flag is automatically set true after the closure has been called.

Types

type Model

type Model struct {
	AP     network.AP
	IP     wifinina.IPAddress
	Time   time.Time
	Retry  uint
	Status Status
}

Model defines a singleton for global data shared by all consuming packages.

The instance variable of this type is private, so consumers must use one of the package's exported functions to access or modify its content, which provide automatic synchronization.

func Get

func Get() (changed bool, data Model)

Get safely returns the model's changed flag and a copy of the Model data (as it was defined when Get was called). The changed flag is automatically set false after reading.

type Status

type Status uint8

Status represents the current position of the program state machine.

const (
	StatusIdle Status = iota
	StatusDisconnected
	StatusConnecting
	StatusUnsynchronized
	StatusSynchronized
)

Constants defining each possible program Status.

Jump to

Keyboard shortcuts

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