eneural-net / async_task

Asynchronous tasks and parallel executors, supporting all Dart platforms (JS/Web, Flutter, VM/Native) through transparent internal implementations with `dart:isolate` or only `dart:async`, easily bringing concepts similar to Thread Pools to Dart, without having to deal with `Isolate` and port/channel complexity.
Apache License 2.0
53 stars 4 forks source link

Working with generics #9

Closed tomasweigenast closed 1 year ago

tomasweigenast commented 2 years ago

Hi. I just wordering how this can work with generic tasks. Because the following:

List<AsyncTask> _taskTypeRegister() => [
  _FuzzySearchTask(_FuzzySearchTaskArgs(tokenSearchers: const [], fullSearcher: Bitap.empty(), identifiers: null, tokens: [], words: [], options: FuzzyOptions()))
];

Won't work for

class _FuzzySearchTask<T extends Object> extends AsyncTask<_FuzzySearchTaskArgs<T>, List<Result<T>>> {

At the moment at looking up a _FuzzySearchTask of type <User> for example, it will fail because _FuzzySearchTask<User> is not registered.

gmpassos commented 2 years ago

Maybe this is a simple bug.

Can you make a simple project with a working example of this case?

Regards

tomasweigenast commented 2 years ago

@gmpassos it is not a bug. Its how Dart works. At the moment of registering the task, it gets registered as _FuzzySearchTask<dynamic>

gmpassos commented 2 years ago

Maybe we can workaround the Dart limitations. I just need a simple example to work on.