-
Notifications
You must be signed in to change notification settings - Fork 55
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
Feature: async Deserialize/Serialize #91
Comments
Can you show me an example how you are working now and how you mean that? We are coming from Angular/RXJS and we usually work with the pipe operator to achieve what you like to do (at least I think so). |
Hi, the method we are using to get our plugins is async so we have to use await to get the result in our deserialize method. The issue here is that the JsonCustomConvert interface doesn't provide a promise or promiseLike so we can't await the deserialize on the interface. See example: export class PluginConverter2 implements JsonCustomConvert<Base> {
private jsonConvert = new JsonConvert(undefined, undefined, true);
serialize(plugin: Base) {
return this.jsonConvert.serialize(plugin);
}
async deserialize(plugin: Base) {
const type = await Helper.getType(plugin.type);
return this.jsonConvert.deserialize(plugin, type);
}
} |
Can't you wait until the plugin is loaded before the deserialization? What kind of "magic" is happening in Helper.getType? I would just execute this code before doing the deserialization. |
Hi Andreas What if the plugin can only be loaded when the deserialization happens? i.e. what if the So the |
I see, thanks for your comments. I don't know yet if this can be implemented without a breaking change. If not, I would postpone this for v2.0. As soon as I work on the library, I will look into it. |
@andreas-aeschlimann any update on this? |
@seanbotha123, did you manage to find a workaround? I'm facing the same problem myself, and I use this in combination with TypeORM, which makes returning a promise infeasable. |
Hi @gsusI, Our solution was basically to go fetch the needed types before running the deserialize call and an then getting the types from a helper as it was deserializing. Hope this helps. |
Hi, will it be possible to add serialize/deserialize methods that return Promises? Our use case here is we are loading types from a server call and need to await the server result before continuing with the deserialize logic.
The text was updated successfully, but these errors were encountered: