Comments (7)
I haven't looked much into it, but I initially thought we could get positional and named things out of it, similar to the constructor, and do something about it?
from auto_mappr.
Oh, yes, thanks, I just found out there is RecordType
😄 in the anlayzer
library with the namedFields
and positionalFields
getters, I will try to get something out of that 👍
from auto_mappr.
To implement for the Dart 3 records, in my opinion, I think it would be better to first convert it to a map first for it to work, for example like a toMap()
extension function,
final record1 = (2, 'hello', true);
print(record1.toMap()) // prints {'$1': 2, '$2' : 'hello', '$3' : true}
but it seems difficult to implement. And it is almost impossible according to what is here.
Or is there something I'm missing?
from auto_mappr.
I've been trying to mess around with some things, what if we have the type Record
use as a primitive type 🤔? Like what is in this extension.
extension DartTypeExtension on DartType {
bool get isPrimitiveType =>
isDartCoreNum ||
isDartCoreInt ||
isDartCoreDouble ||
isDartCoreString ||
isDartCoreBool ||
isDartCoreEnum ||
isDartCoreSymbol ||
isDartCoreRecord;
}
And have something like this
@AutoMappr([
MapType<RecordHolderDto, RecordHolder>(),
])
class Mappr extends $Mappr {}
class RecordHolder {
final Record value;
RecordHolder(this.value);
}
class RecordHolderDto {
final Record value;
RecordHolderDto(this.value);
}
I still doubt if this is right, but I just want show it, before I create a PR.
from auto_mappr.
I think the difference between primitives and iterable/map right now is that we pass a primitive just like that, and we map each part of iterable/map.
Meaning in the Iterable I can have List<UserDto> -> List<User>
, in Map, I can have Map<KeyDto, ValueDto> -> Map<Key, Value>
, and in Record, I can have (UserDto, AddressDto, school: SchoolDto, ...) -> (User, Address, school: School, ...)
.
I am not sure how the records mapping should work exactly either because we didn't use it yet. :D That is what this issue is about -- do research and probably do it similarly to list/map mappings. It's for sure a tricky issue to do.
from auto_mappr.
Yes, it is quite tricky one to implement. I will make more findings and try to imitate that of map/list.
Thanks for the feedback.
from auto_mappr.
Will be available in v2
from auto_mappr.
Related Issues (20)
- Support reverse flag in build.yaml config HOT 2
- Global converter not found when used with reverse flag HOT 2
- Nullable input/output with type converters HOT 6
- Strict mode HOT 6
- Build Options as Config object HOT 1
- Switch to DCM OSS
- Custom MapType HOT 5
- Generation fails when required TARGET field doesn't exist in SOURCE even with whenNull HOT 2
- Combining multiple SOURCEs into one single TARGET HOT 2
- Custom Mapping Futures HOT 3
- Async support HOT 2
- Anyone using auto_mappr in production? HOT 2
- Support field name mapping in reverse mode
- Global Methods dont work with out type HOT 10
- Field ignores whenNull and ignoreNull HOT 3
- Generated code for classes without ctors ignores 'from' argument HOT 7
- Move where from extension to static function
- Extend tryConvert method for catching mapping exceptions
- Enum set to null for unknown values HOT 1
- Possibility to ignore elements in a list when mapping goes wrong for one element HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto_mappr.