hyperapp

Update item in tree structure by reference and return updated tree structure

前提是你 提交于 2020-03-05 06:23:50
问题 I am currently learning functional programming using HyperappJS (V2) and RamdaJS. My first project is a simple blog app where users can comment on posts or other comments. The comments are represented as a tree structure. My state looks something like this: // state.js export default { posts: [ { topic: `Topic A`, comments: [] }, { topic: `Topic B`, comments: [ { text: `Comment`, comments: [ /* ... */ ] } ] }, { topic: `Topic C`, comments: [] } ], otherstuff: ... } When the user wants to add