Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate NewModel() constructors; use New() instead #93

Merged
merged 1 commit into from Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions help/help.go
Expand Up @@ -57,8 +57,8 @@ type Model struct {
Styles Styles
}

// NewModel creates a new help view with some useful defaults.
func NewModel() Model {
// New creates a new help view with some useful defaults.
func New() Model {
keyStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
Light: "#909090",
Dark: "#626262",
Expand Down Expand Up @@ -90,6 +90,11 @@ func NewModel() Model {
}
}

// NewModel creates a new help view with some useful defaults.
//
// Deprecated. Use New instead.
var NewModel = New

// Update helps satisfy the Bubble Tea Model interface. It's a no-op.
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
return m, nil
Expand Down
9 changes: 7 additions & 2 deletions list/list.go
Expand Up @@ -149,8 +149,8 @@ type Model struct {
delegate ItemDelegate
}

// NewModel returns a new model with sensible defaults.
func NewModel(items []Item, delegate ItemDelegate, width, height int) Model {
// New returns a new model with sensible defaults.
func New(items []Item, delegate ItemDelegate, width, height int) Model {
styles := DefaultStyles()

sp := spinner.NewModel()
Expand Down Expand Up @@ -196,6 +196,11 @@ func NewModel(items []Item, delegate ItemDelegate, width, height int) Model {
return m
}

// NewModel returns a new model with sensible defaults.
//
// Deprecated. Use New instead.
var NewModel = New

// SetFilteringEnabled enables or disables filtering. Note that this is different
// from ShowFilter, which merely hides or shows the input view.
func (m *Model) SetFilteringEnabled(v bool) {
Expand Down
9 changes: 7 additions & 2 deletions paginator/paginator.go
Expand Up @@ -96,8 +96,8 @@ func (m Model) OnLastPage() bool {
return m.Page == m.TotalPages-1
}

// NewModel creates a new model with defaults.
func NewModel() Model {
// New creates a new model with defaults.
func New() Model {
return Model{
Type: Arabic,
Page: 0,
Expand All @@ -114,6 +114,11 @@ func NewModel() Model {
}
}

// NewModel creates a new model with defaults.
//
// Deprecated. Use New instead.
var NewModel = New

// Update is the Tea update function which binds keystrokes to pagination.
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
switch msg := msg.(type) {
Expand Down
9 changes: 7 additions & 2 deletions progress/progress.go
Expand Up @@ -154,8 +154,8 @@ type Model struct {
scaleRamp bool
}

// NewModel returns a model with default values.
func NewModel(opts ...Option) Model {
// New returns a model with default values.
func New(opts ...Option) Model {
m := Model{
id: nextID(),
Width: defaultWidth,
Expand All @@ -176,6 +176,11 @@ func NewModel(opts ...Option) Model {
return m
}

// NewModel returns a model with default values.
//
// Deprecated. Use New instead.
var NewModel = New

// Init exists satisfy the tea.Model interface.
func (m Model) Init() tea.Cmd {
return nil
Expand Down
9 changes: 7 additions & 2 deletions spinner/spinner.go
Expand Up @@ -193,14 +193,19 @@ func (m Model) Visible() bool {
return !m.hidden() && !m.finished()
}

// NewModel returns a model with default values.
func NewModel() Model {
// New returns a model with default values.
func New() Model {
return Model{
Spinner: Line,
id: nextID(),
}
}

// NewModel returns a model with default values.
//
// Deprecated. Use New instead.
var NewModel = New

// TickMsg indicates that the timer has ticked and we should render a frame.
type TickMsg struct {
Time time.Time
Expand Down
7 changes: 6 additions & 1 deletion textinput/textinput.go
Expand Up @@ -153,7 +153,7 @@ type Model struct {
}

// NewModel creates a new model with default settings.
func NewModel() Model {
func New() Model {
return Model{
Prompt: "> ",
BlinkSpeed: defaultBlinkSpeed,
Expand All @@ -174,6 +174,11 @@ func NewModel() Model {
}
}

// NewModel creates a new model with default settings.
//
// Deprecated. Use New instead.
var NewModel = New

// SetValue sets the value of the text input.
func (m *Model) SetValue(s string) {
runes := []rune(s)
Expand Down