pbomb / flow-immutable-models

Generates model classes from Flow types using Immutable.js
42 stars 8 forks source link

Provide `toJS` and `toJSON` functions #15

Open pbomb opened 7 years ago

pbomb commented 7 years ago

In order to support serialization, provide a toJS (and toJSON alias) function to convert the ImmutableModel into its modelType form.

Fi3 commented 7 years ago

Why didn't you add toJSON? I think that toJSON would be a lot faster than toJS to encode the model as a string. Is that right?

pbomb commented 7 years ago

Yeah, you're right. I'll put together a pull request to add toJSON as a shallow operation which will work better when using JSON.stringify

pbomb commented 7 years ago

I'm going to hold off on this until Immutable-JS 4.0.0 is released. The current version doesn't have correct flow types for the toJSON function.