Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add listener for initial state on flame_bloc (#2382)
While analyzing the tests for flame_bloc, I stumbled upon an interesting conundrum. It seems that the initialState provided does not trigger a state change callback through onNewState. While that is in line with bloc, I think for most game use cases it is important to keep track of the "last" state of stuff - and in fact most of our existing examples do use the library in that way, to keep track of the last (i.e., the current) state. However, doing so generically is not simple with the current library because of how the initial state is not provided. While you could initialize your last manually, if there is a dynamic initial state, it would not be trivial to wire it up. This, therefore, adds a new listener of onInitialState, maintaining the behaviour of onNewState. Note: this solves the last unused reference from this issue by using it on the new tests.
- Loading branch information
1 parent
532899c
commit 01121c2
Showing
3 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters