eventbus

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ChannelSize = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type DidChangeEvent

type DidChangeEvent struct {
	Context context.Context

	Dir        document.DirHandle
	LanguageID string
}

DidChangeEvent is an event to signal that a file in directory has changed.

It is usually emitted when a document is changed via a language server text synchronization event.

type DidChangeWatchedEvent

type DidChangeWatchedEvent struct {
	Context context.Context

	// RawPath contains an OS specific path to the file or directory that was
	// changed. Usually extracted from the URI.
	RawPath string
	// IsDir is true if we were able to determine that the path is a directory.
	IsDir      bool
	ChangeType protocol.FileChangeType
}

DidChangeWatchedEvent is the event that is emitted when a client notifies the language server that a directory or file was changed outside of the editor.

type DidOpenEvent

type DidOpenEvent struct {
	Context context.Context

	Dir        document.DirHandle
	LanguageID string
}

DidOpenEvent is an event to signal that a directory is open in the editor or important for the language server to process.

It is usually emitted when a document is opened via a language server text synchronization event. It can also be fired from different features to signal that a directory should be processed in other features as well.

type DiscoverEvent

type DiscoverEvent struct {
	Context context.Context

	Path  string
	Files []string
}

DiscoverEvent is an event that is triggered by the walker when a new directory is walked.

Most features use this to create a state entry if the directory contains files relevant to them.

type EventBus

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

EventBus is a simple event bus that allows for subscribing to and publishing events of a specific type.

It has a static list of topics. Each topic can have multiple subscribers. When an event is published to a topic, it is sent to all subscribers.

func NewEventBus

func NewEventBus() *EventBus

func (*EventBus) DidChange

func (n *EventBus) DidChange(e DidChangeEvent)

func (*EventBus) DidChangeWatched

func (n *EventBus) DidChangeWatched(e DidChangeWatchedEvent)

func (*EventBus) DidOpen

func (n *EventBus) DidOpen(e DidOpenEvent)

func (*EventBus) Discover

func (n *EventBus) Discover(e DiscoverEvent)

func (*EventBus) ManifestChange

func (n *EventBus) ManifestChange(e ManifestChangeEvent)

func (*EventBus) OnDidChange

func (n *EventBus) OnDidChange(identifier string, doneChannel <-chan struct{}) <-chan DidChangeEvent

func (*EventBus) OnDidChangeWatched

func (n *EventBus) OnDidChangeWatched(identifier string, doneChannel <-chan struct{}) <-chan DidChangeWatchedEvent

func (*EventBus) OnDidOpen

func (n *EventBus) OnDidOpen(identifier string, doneChannel <-chan struct{}) <-chan DidOpenEvent

func (*EventBus) OnDiscover

func (n *EventBus) OnDiscover(identifier string, doneChannel <-chan struct{}) <-chan DiscoverEvent

func (*EventBus) OnManifestChange

func (n *EventBus) OnManifestChange(identifier string, doneChannel <-chan struct{}) <-chan ManifestChangeEvent

func (*EventBus) OnPluginLockChange

func (n *EventBus) OnPluginLockChange(identifier string, doneChannel <-chan struct{}) <-chan PluginLockChangeEvent

func (*EventBus) PluginLockChange

func (n *EventBus) PluginLockChange(e PluginLockChangeEvent)

func (*EventBus) SetLogger

func (eb *EventBus) SetLogger(logger *log.Logger)

type ManifestChangeEvent

type ManifestChangeEvent struct {
	Context context.Context

	Dir        document.DirHandle
	ChangeType protocol.FileChangeType
}

ManifestChangeEvent is an event that should be fired whenever the module manifest file changes.

type PluginLockChangeEvent

type PluginLockChangeEvent struct {
	Context context.Context

	Dir        document.DirHandle
	ChangeType protocol.FileChangeType
}

PluginLockChangeEvent is an event that should be fired whenever the lock file changes.

type Subscriber

type Subscriber[T any] struct {
	// contains filtered or unexported fields
}

Subscriber represents a subscriber to a topic

type Topic

type Topic[T any] struct {
	// contains filtered or unexported fields
}

Topic represents a generic subscription topic

func NewTopic

func NewTopic[T any]() *Topic[T]

NewTopic creates a new topic

func (*Topic[T]) Publish

func (eb *Topic[T]) Publish(event T)

Publish sends an event to all subscribers of a specific topic

func (*Topic[T]) Subscribe

func (eb *Topic[T]) Subscribe(doneChannel <-chan struct{}) <-chan T

Subscribe adds a subscriber to a topic

Jump to

Keyboard shortcuts

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