Open jeffbski opened 8 years ago
Seems like a sensible idea to me, its not something I'm likely to work on myself but I'll happily review and help land a PR
Sounds good. I'll start up a PR in the near future and we can take it from there.
That's pretty cool, thanks!
Thanks for creating this project, using transit with immutable.js is awesome. You've packaged up some great functionality here, especially with handling records too.
I was wondering if we could add another method or option that would coerce normal json objects and arrays into immutable maps and lists during deserialization.
Here is the use case I am looking at.
With the methods you have now, it is easy to serialize immutable maps, lists, records into transit format and then deserialize them back into the same form. However on the server if we are fetching from a service or database we might not have immutable maps and lists, so rather than convert the standard objects and arrays it would be nice to simply serialize this (as is) and then coerce them on the client into the immutable maps and lists. On the server we are probably getting back json or objects so it would be more efficient to just send them along as is without a conversion first.
Then we just create maps and lists when we read the transit objects and arrays.
I believe that in doing this we could also support just pure json directly since transit is built on it. So thus whether the server is sending transit encoded objects and arrays or it is just pure json, the reader could create immutable maps and lists from either stream.
This lets us keep things in immutable structures on the client that are created directly upon deserializing the transit stream and on the server we can stay efficient serving transit or json from objects and arrays.
Hopefully this all makes sense. I believe I have some somewhere that setup this type of mapping if I need to dig it up, but I'm expecting that you already know how to make this happen given your effort on the project.
Let me know what you think.