mobXAdapter top-level property
JsonMapperAdapter
mobXAdapter
final
Adapter definition, should be passed to the Json Mapper initialization method: initializeJsonMapper(adapters: mobXAdapter);
Implementation
final mobXAdapter = JsonMapperAdapter(
title: 'MobX Adapter',
refUrl: 'https://github.com/mobxjs/mobx.dart',
url:
'https://github.com/k-paxian/dart-json-mapper/tree/master/adapters/mobx',
typeInfoDecorators: {
0: mobXTypeInfoDecorator
},
converters: {
ObservableList: defaultIterableConverter,
ObservableSet: defaultIterableConverter,
ObservableMap: mapConverter,
// Value converters for Observable variations
typeOf<Observable<String>>(): observableStringConverter,
typeOf<Observable<DateTime>>(): observableDateTimeConverter,
typeOf<Observable<bool>>(): observableBoolConverter,
typeOf<Observable<num>>(): observableNumConverter,
typeOf<Observable<int>>(): observableIntConverter,
typeOf<Observable<double>>(): observableDoubleConverter
},
valueDecorators: {
// Value decorators for ObservableList variations
typeOf<ObservableList<DateTime>>(): (value) =>
ObservableList<DateTime>.of(value.cast<DateTime>()),
typeOf<ObservableList<String>>(): (value) =>
ObservableList<String>.of(value.cast<String>()),
typeOf<ObservableList<num>>(): (value) =>
ObservableList<num>.of(value.cast<num>()),
typeOf<ObservableList<int>>(): (value) =>
ObservableList<int>.of(value.cast<int>()),
typeOf<ObservableList<double>>(): (value) =>
ObservableList<double>.of(value.cast<double>()),
typeOf<ObservableList<bool>>(): (value) =>
ObservableList<bool>.of(value.cast<bool>()),
// Value decorators for ObservableSet variations
typeOf<ObservableSet<DateTime>>(): (value) =>
ObservableSet<DateTime>.of(value.cast<DateTime>()),
typeOf<ObservableSet<String>>(): (value) =>
ObservableSet<String>.of(value.cast<String>()),
typeOf<ObservableSet<num>>(): (value) =>
ObservableSet<num>.of(value.cast<num>()),
typeOf<ObservableSet<int>>(): (value) =>
ObservableSet<int>.of(value.cast<int>()),
typeOf<ObservableSet<double>>(): (value) =>
ObservableSet<double>.of(value.cast<double>()),
typeOf<ObservableSet<bool>>(): (value) =>
ObservableSet<bool>.of(value.cast<bool>()),
});