dart:mirror is not cross-platform #59682
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
library-mirrors
type-question
A question about expected behavior or functionality
web-platform
When working with Dart, there are some difficulties in solving the following task.
The task is to write a Chain class that will store a set of functions and execute them when necessary. The class, when executing the function chain, should trigger rollback actions for all the completed tasks in case of an error. This can be useful when you need to either execute all the functions or execute none if an error occurs.
When starting the chain, arguments can be passed to it. The chain stores these arguments. To call the functions from storage, the required arguments are fetched. The list of required arguments is determined based on dart:mirror, which extracts parameter names and information about them from the function's description. However, the solution based on dart:mirror is not cross-platform. Extracting names using the toString method for function signatures may not be very convenient, fast, and also is not cross-platform.
Is it possible to add a limited version of dart:mirrors in the Dart SDK that would be cross-platform and allow extracting the following information from functions: whether an argument is named or not, and the name of the argument?
A simplified code for working with chains is presented below.
The text was updated successfully, but these errors were encountered: