Comments (9)
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.
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.
@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.
@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.
@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.
That's what I'm talking about. Who wants to refactor REST backend to support transit?
from immutable-js.
@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.
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.
Okay guys, I finally agreed. Will give transit-js a try.
from immutable-js.
Related Issues (20)
- createSerializableStateInvariantMiddleware for Record in React Redux TS HOT 1
- Supporting wildcards HOT 7
- Converting a Seq to a list causes RangeError (max call size exceeded) HOT 1
- 4.2.0: partition missing in flow HOT 3
- Question: Wiki article for upgrading to v4 HOT 3
- `toJS` breaks type compatibility between records with object values HOT 8
- Wrong typescript declarations for `.update()` method (continued) HOT 2
- Record with more keys should be assignable to Record with less keys if type is a subset of the first one
- An argument for 'reviver' was not provided. HOT 4
- ReferenceError: Immutable is not defined HOT 9
- Highlight inputs where `Set` can't maintain uniqueness HOT 4
- Flow type definition outdated, not working with last year changes HOT 1
- Urgent: Package Installation Reveals Multiple Vulnerabilities HOT 1
- Type predicate missing on isOrderedSet function type declaration
- support deno HOT 2
- immutable default import in 5.x
- version 4.3.3 breaks TS/Angular/webpack HOT 2
- Typescript: Implement `MapOf::merge `
- Extract sort function from Collection types HOT 6
- Enhancement: Custom equals HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immutable-js.