GithubHelp home page GithubHelp logo

Comments (9)

sophiebits avatar sophiebits commented on May 11, 2024

I was just wondering about this too today. Maybe it makes sense to recommend something like transit-js for serialization though – @swannodette's blog post serializes into regular JSON objects and arrays but I think it's easy to switch the tags.

from immutable-js.

Tvaroh avatar Tvaroh commented on May 11, 2024

Hi, Ben. I read David's post this morning. While I like this stuff I don't think transit can replace JSON for server communication. One can't just take his REST endpoint and migrate it to another transport. Most people would stay with JSON though.

from immutable-js.

swannodette avatar swannodette commented on May 11, 2024

@Tvaroh the point of my post was that the endpoint can appear to be a normal JSON even though it's actually Transit JSON. For example you could follow my post exactly and just add read/write handlers for Immutabe Sets and it will just work - Transit represents sets today as {"~#set": [1,2,3]} - perfectly valid JSON and no one needs to be the wiser. Ordered collection types don't present any challenges - you can install your own tag ~#orderedSet and ~#orderedMap, the wire rep of the data is an array so order on the read side can be preserved.

All that aside I do think this ticket is asking for something that seems outside the scope of Immutable - serialization concerns like this seems best handled elsewhere and if not by Transit by some other means.

from immutable-js.

Tvaroh avatar Tvaroh commented on May 11, 2024

@swannodette sorry, I don't understand. How my Scala backend can start working with transit? Immutable provides fromJS/toJS - and I don't think it's outside of its scope to do this conversions correctly for supported types.

from immutable-js.

swannodette avatar swannodette commented on May 11, 2024

@Tvaroh Scala users can use https://github.com/cognitect/transit-java for now. I've expressed the full extent of my opinion here :)

from immutable-js.

Tvaroh avatar Tvaroh commented on May 11, 2024

That's what I'm talking about. Who wants to refactor REST backend to support transit?

from immutable-js.

swannodette avatar swannodette commented on May 11, 2024

@Tvaroh I guess don't see what refactoring needs to be done - at least in my experience a REST backend often emits response as .toXML or .toJSON regardless of language. You can add transit.write to that list and in fact reuse all of your existing JSON infrastructure.

Of course a backend may not be so be clean warranting front-end ad-hoc solutions as the kind suggested in this thread. That to me is a warning sign.

from immutable-js.

leebyron avatar leebyron commented on May 11, 2024

Yeah, I think this is out of scope for immutable-js because it's not intended to be a transport and there is no standard for this (and I don't want to force a proposed standard). For example, what if someone sets the key "type" on a map/set? There's then a collision.

I do recommend using something like transit-js for this. Or, a function to do this should be pretty straight-forward. Then our fromJS method should already support this by providing a converter function as the 2nd arg and checking for this "type" key.

from immutable-js.

Tvaroh avatar Tvaroh commented on May 11, 2024

Okay guys, I finally agreed. Will give transit-js a try.

from immutable-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.