Naming Conventions
Ce contenu n’est pas encore disponible dans votre langue.
The following naming conventions are simply recommendations and are completely optional. Feel free to use whatever naming conventions you prefer. You may find some of the examples/documentation do not follow the naming conventions mainly for simplicity/conciseness. These conventions are strongly recommended for large projects with multiple developers.
Events should be named in the past tense because events are things that have already occurred from the bloc’s perspective.
BlocSubject
+ Noun (optional)
+ Verb (event)
Initial load events should follow the convention: BlocSubject
+ Started
✅ Good
❌ Bad
States should be nouns because a state is just a snapshot at a particular point in time. There are two common ways to represent state: using subclasses or using a single class.
BlocSubject
+ Verb (action)
+ State
When representing the state as multiple subclasses State
should be one of the following:
Initial
| Success
| Failure
| InProgress
BlocSubject
+ State
When representing the state as a single base class an enum named BlocSubject
+ Status
should be used to represent the status of the state:
initial
| success
| failure
| loading
.
✅ Good
❌ Bad