I'm looking to implement what is commonly called the Facade pattern:
https://refactoring.guru/design-patterns/facade
Essentially the idea is to encapsulate a complex/general API and provide a simplified/focused API for the App UI to consume.
So for example I would want to be able to
- Create a singleton class called Wifi
- That class exposes init()
, startScan()
, stopScan()
methods that we can be hook up actions
- Internally the Wifi class is using some specific pub pkg for Wifi, but the UI doesn't know/care
- Internally the Wifi class may have state, like an internal _isCurrentlyScanning
bool, etc
What's the recommended approach for something like this in FF? I could create a custom action for each separate method, but that doesn't work if I need to share state between the actions which could lead to a lot of wasted boilerplate.