[spike] allo interface v2
at the moment the allo interface is a plain typescript interface with methods that return operations, those operations have a callback to execute and emit some events, this is because we need to track when an operation is done, whether it is successful or not and the steps in between, to show it to the user in the UI
this has worked well so far for the Allo migration, it gave us a common pattern to follow between features, but there are a couple of things that worry me:
There's clearly a pattern we use when doing an operation:
- User initiates operation
- We open a pop up
- We update the pop up with the steps and their status
- If operation fails, show an error and allow the user to retry
- If operation is successful, redirect the user
This pattern is repeated across manager, explorer, builder to varying levels of quality. The error handling is not the best and sometimes the user has to go into the console to figure out what's going on. In Manager and Explorer we use these Contexts that do some state tracking with hundreds of lines of code, the tests are heavily mocked, they are not very effective at catching problems, but are very hard to update. Normally I wouldn't mind the number of lines of code by themselves, but in this case it feels very unnecessary.
Each app uses a slightly different design and repeats the exact same logic.
I also noticed that some Allo operations return Promises which messes up a bit the consistency. I think there's an opportunity to narrow down the Allo interface types even further:
- Allo operations always return an AlloOperation (no Promise)
- Allo operations always return Result, no need to explicitly define it like we do now
This would make it easier to implement a React component and hook that tracks the state of an operation and renders a progress modal, this component would be shared between all apps.
We can have an exhaustive test suite for this component and in the UI tests we just test that they're calling the operation.