flame-engine / flame-engine/flame

Timer and TimerComponent APIs are inconsistent

Open
#2,386 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
10.8k
Forks
1k
Avg merge
1d 20h
Merged PRs (30d)
21

Description

Taking a look at Timer and TimerComponent, I realized they have a different nomenclature on their APIs:

On [TimerComponent](https://github.com/flame-engine/flame/blob/main/packages/flame/lib/src/components/timer_component.dart#L20), the length/duration of the timer is called `period` and it is a named parameter. That is a good name for when repeat is true.

But on the underlying [Timer](https://github.com/flame-engine/flame/blob/main/packages/flame/lib/src/timer.dart#L13) implementation, it is actually called `limit` and it is not a named parameter. That name feels better for non-repeating timers.

-> I do not have a strong preference for the parameter name, but I think it should be consistent.
-> I think whether it is named-parameter or not should also be consistent - but I do tend to prefer the named-parameter on this matter, as it is more readable from the call site.

Thoughts? I can happily update one or the other depending on everyone's preferences.
It is a breaking change, but I think keeping them consistent is very important to keep simplicity and avoid confusion for our users (for example when changing code from one to the other).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.