schultek/dart_mappable

Can not use Isolate.run with the mapper class

Closed this issue · 2 comments

Hello!

I have a code like this:

SomeMapper.fromMap(data)

It works fine but now it is heavy and I was trying to move it to an isolate. Like this:

Isolate.run(() => SomeMapper.fromMap(data) )

The problem is that it doesn't work. It throws a MapperException that it can not resolve a type (Cannot resolve type from property "XX". Invalid or unregistered type).
But without the Isolate, it works fine.

Do you have any idea why this is happening?

Any calls to initializeMappers() or SomeMapper.ensureInitialized() need to be repeated since isolates don't have shared global memory.

Oh yeah. Thank you!