gate

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 72 modules, 458 packages

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.

Documentation

Overview

Package gate contains a gated function callback registration implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gate

type Gate[T comparable] struct {
	// contains filtered or unexported fields
}

Gate implements a gated function callback registration with comparable conditions.

func (*Gate[T]) Register

func (g *Gate[T]) Register(fn func(), depends ...T)

Register a callback function that will be called when all the provided dependent conditions are true. After all conditions are true, the callback function is removed from the registration and will not be called again. Thread Safe.

func (*Gate[T]) Set

func (g *Gate[T]) Set(condition T, value bool) bool

Set marks the associated condition to the given value. If the condition is already set as that value, then this is a no-op. Returns true if there was an update detected. Thread safe.

Jump to

Keyboard shortcuts

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