The question of how to mix async return types and type parameters has often been raised on the forum. They aren’t allowed in Motoko.
I have written a blog post about my favorite solution, a workaround, which I have used successfully in practice: Asynchronous generics in Motoko - by MR Research AG
Also try it live on embed.motoko.org
If you have any use cases for shareable generics then please post them below.
I have found at least these links where the question was raised, ordered by date:
- Parametric polymorphism and async (Sep 2020)
- Motoko Sharable Generics (Nov 2021)
- Shared types, generics, and async* (April 2023)
- Question: Shareable generics · Issue #4604 · dfinity/motoko · GitHub (July 2024)
If you know other link then please post them as well. I would be interested if the workaround is good enough for those use cases or not.