Hi, great library ! I use it a lot !
Unfortunately I came across a problem I could not figure how to solve.
I have a hierarchical structure representing a collapsible nested list items. The type is:
export interface NavNode {
readonly title: string,
readonly icon?: string,
readonly opened?: boolean,
readonly children?: NavTree
}
export interface NavTree {
readonly [url: string]: NavNode
}
And it looks like:
{
"/computer-sciences/": {
title: "Computer sciences",
opened: false,
children: {
"artificial-intelligence/": {
title: "Artificial intelligence",
opened: false,
children: {
"machine-learning/": {
title: "Machine learning",
opened: false,
children: {
"introduction/": {
title: "Introduction"
},
"common-models/": {
title: "Common Models"
},
"common-training-methods/": {
title: "Common training methods"
},
"ensemble-techniques/": {
title: "Ensemble techniques"
},
}
}
}
}
}
}
}
My problem arises when I try to handle a click on an internal non-leaf node. I can't write getProp
as, for example:
navTree => navTree["/computer-sciences/"]["children"]["artificial-intelligence/"]["opened"]
Because I don't know the path until a node is clicked and the information on the node is an array describing it's path, like:
["/computer-sciences/", "artificial-intelligence/"]
It would be nice if there was a feature of iassign
allowing an array for the path of the property to update. In the previous case, the array would be:
["/computer-sciences/", "children", "artificial-intelligence/", "opened"]
And the usage may look like:
iassign(
obj,
["/computer-sciences/", "children", "artificial-intelligence/", "opened"],
opened => !opened)