celest-dev / celest

The Flutter cloud platform
https://celest.dev
Other
232 stars 12 forks source link

Add Serializers to the documentation, so that it's part of the public API #56

Open marcglasberg opened 4 months ago

marcglasberg commented 4 months ago

I think it's very important that we're able to access Celest's serialization for other purposes:

So, basically, explain that this is possible:

Object? toJsonPersistor() => Serializers.instance.serialize<AvailableStock>(this);

factory AvailableStock.fromJsonPersistor(Object? value) =>
      Serializers.instance.deserialize<AvailableStock>(value);

Note: Maybe make it a bit simpler, but defining two extra static methods, serialize and deserialize:

static Object? serialize<T>(T value) => instance.serialize(value);
static T deserialize<T>(Object? value) => instance.deserialize(value);

So that we can write:

Object? toJsonPersistor() => Serializers.serialize<AvailableStock>(this);
factory AvailableStock.fromJsonPersistor(Object? value) => Serializers.deserialize<AvailableStock>(value);

That way, Celest users don't have to use instance, and we don't make instance part of the public API. But feel free to ignore these if you don't think it's a good idea.

dnys1 commented 4 months ago

Thanks, Marcelo!