Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marcglasberg opened this issue Mar 5, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@marcglasberg
Copy link

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

  • It's very useful, why not?
  • If we have access to it, you make it testable.
  • Third, making it accessible will help when we need to migrate when the model evolves.
  • If you don't, you force me to use other serialization techniques, which is duplicating not only the code, but may result in different serializations, which complicates things for no reason.

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
Copy link
Member

dnys1 commented Mar 5, 2024

Thanks, Marcelo!

@dnys1 dnys1 added the documentation Improvements or additions to documentation label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants