by Findeton · 8y ago · 0 comments
The small project involves getting rid of reducers in react redux, by creating a modified version of JSON.
The big project is a new social network. A selling point is recovering the idea of Google + circles, but using groups instead (like in Whatsapp). Think about merging WhatsApp and Facebook together, you should be able to publish things in the same way you do messaging through WhatsApp.
Good luck with the social network. Seems like a tough job.
This is how it would work: In the front end (like in react-redux) you have your state variable and then you normally make a request to the backend, which the backend returns this "JSON2" object, which you can merge automatically (with JSON2.merge method) to create the new state, without requiring reducers. The only thing is that the back-end would need to be aware of how the front-end state structure looks like (it doesn't need to keep track of the current state though).
// the front-end state
let state = { some: "things", nested: { something: { what: "what", } }, other: [2,3] }
// action is a string with JSON2 format that comes from a query to the back-end. Take the "..." literally
let action = "{ ..., nested: { something: { ..., more: "manymore" } }, other: [1, ...] }"
// create the new state
state = JSON2.merge(state, action)
// now state is:
state = { some: "things", nested: { something: { what: "what", more: "manymore" } }, other: [1,2,3] }