什么时候应该在 Flutter 中使用 BLoC 模式?
When should I use BLoC pattern in Flutter?
我最近读到 BLoC(业务逻辑组件),我正在构建一个应用程序以从 api 检索数据,我想知道什么时候我应该创建一个 bloc 而当我不应该使用 Flutter_BLoC
包时,似乎我必须为 每个屏幕创建一个 bloc 我说得对吗?
Whenever you start looking into architectures for Flutter there’s no way around the BLoC pattern, but how does it work and how do we implement it?
BLoC stands for Business Logic Component and is one of the more popular approaches when it comes to architectures in Flutter. By placing a BLoC between our screen and data layer it gives us the possibility to pass data between our repositories and widgets and update the UI whenever data changes, without having to manually update the state. Coming from Android it actually has some similarities with the ViewModel & LiveData structure we use in native development.
我最近读到 BLoC(业务逻辑组件),我正在构建一个应用程序以从 api 检索数据,我想知道什么时候我应该创建一个 bloc 而当我不应该使用 Flutter_BLoC
包时,似乎我必须为 每个屏幕创建一个 bloc 我说得对吗?
Whenever you start looking into architectures for Flutter there’s no way around the BLoC pattern, but how does it work and how do we implement it?
BLoC stands for Business Logic Component and is one of the more popular approaches when it comes to architectures in Flutter. By placing a BLoC between our screen and data layer it gives us the possibility to pass data between our repositories and widgets and update the UI whenever data changes, without having to manually update the state. Coming from Android it actually has some similarities with the ViewModel & LiveData structure we use in native development.