tekartik / sembast.dart

Simple io database
BSD 2-Clause "Simplified" License
780 stars 64 forks source link

Export JsonEncodableCodec type #365

Closed TyBarthel closed 9 months ago

TyBarthel commented 1 year ago

Can you please export the JsonEncodableCodec type so we can use that to handle custom type serialization with adapters and override the default on SembastCodec?

alextekartik commented 1 year ago

Done in sembast 3.5.0

Export SembastTypeAdapter and JsonEncodableCodec from utils/type_adapter.dart

As a demo, you can look at a simple adapter (that converts native cloud firestore types) here: https://github.com/tekartik/sembast_flutter_more.dart/tree/master/cloud_firestore_type_adapters

The import is safe (not in src) and will maintained like a regular API (but I did not want to pollute more the main sembast.dart)

import 'package:sembast/utils/type_adapter.dart';
TyBarthel commented 1 year ago

Thanks!

TyBarthel commented 1 year ago

Should probably export JsonEncodableEncoder and JsonEncodableDecoder as well right?

alextekartik commented 1 year ago

Indeed, done in 3.5.0+1. So far I did not use it outside of the package