Sha256: 2cbba49ebb5f88ac1318f4ef276583a32bfcd48caf84ccdc9c475ef22ad74464

Contents?: true

Size: 1.42 KB

Versions: 297

Compression:

Stored size: 1.42 KB

Contents

package react

// A Reactor manages linked cells.
type Reactor interface {
	// CreateInput creates an input cell linked into the reactor
	// with the given initial value.
	CreateInput(int) InputCell

	// CreateCompute1 creates a compute cell which computes its value
	// based on one other cell. The compute function will only be called
	// if the value of the passed cell changes.
	CreateCompute1(Cell, func(int) int) ComputeCell

	// CreateCompute2 is like CreateCompute1, but depending on two cells.
	// The compute function will only be called if the value of any of the
	// passed cells changes.
	CreateCompute2(Cell, Cell, func(int, int) int) ComputeCell
}

// A Cell is conceptually a holder of a value.
type Cell interface {
	// Value returns the current value of the cell.
	Value() int
}

// An InputCell has a changeable value, changing the value triggers updates to
// other cells.
type InputCell interface {
	Cell

	// SetValue sets the value of the cell.
	SetValue(int)
}

// A ComputeCell always computes its value based on other cells and can
// call callbacks upon changes.
type ComputeCell interface {
	Cell

	// AddCallback adds a callback which will be called when the value changes.
	// It returns a Canceler which can be used to remove the callback.
	AddCallback(func(int)) Canceler
}

// A Canceler is used to remove previously added callbacks, see ComputeCell.
type Canceler interface {
	// Cancel removes the callback.
	Cancel()
}

Version data entries

297 entries across 297 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.158 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.157 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.156 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.155 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.154 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.153 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.152 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.151 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.150 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.149 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.148 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.147 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.146 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.145 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.144 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.143 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.142 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.141 tracks/go/exercises/react/interfaces.go
trackler-2.2.1.140 tracks/go/exercises/react/interfaces.go