Documentation
¶
Index ¶
- type SubmitState
- func (s *SubmitState) Clear()
- func (s *SubmitState) Do(ctx context.Context, content string, fn func() error) (err error)
- func (s *SubmitState) IsSubmitting() bool
- func (s *SubmitState) RestorePendingContent()
- func (s *SubmitState) SetOnRestore(onRestore func(content string))
- func (s *SubmitState) SetSubmitting(content string)
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 ¶
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