submit

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SubmitState

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

SubmitState manages the state of content submission operations

func NewSubmitState

func NewSubmitState(onRestore func(content string)) *SubmitState

NewSubmitState creates a new SubmitState with the given restore callback

func (*SubmitState) Clear

func (s *SubmitState) Clear()

Clear clears the submission state without restoring content

func (*SubmitState) Do

func (s *SubmitState) Do(ctx context.Context, content string, fn func() error) (err error)

Do executes a function with proper submission state management It handles the common pattern: SetSubmitting → defer Clear() → error handling with restore Also handles panics by restoring content and re-panicking

func (*SubmitState) IsSubmitting

func (s *SubmitState) IsSubmitting() bool

IsSubmitting returns whether a submission is currently in progress

func (*SubmitState) RestorePendingContent

func (s *SubmitState) RestorePendingContent()

RestorePendingContent restores failed content using the callback and clears submission state

func (*SubmitState) SetOnRestore

func (s *SubmitState) SetOnRestore(onRestore func(content string))

func (*SubmitState) SetSubmitting

func (s *SubmitState) SetSubmitting(content string)

SetSubmitting sets the submission state to true and stores the pending content

Jump to

Keyboard shortcuts

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