While exploring the content metadata component of Alfresco ADF, I came across this typescript function that has left me puzzled:
private saveNode({ changed: nodeBody }): Observable<Node> {
return this.nodesApiService.updateNode(this.node.id, nodeBody);
}
I'm struggling to make sense of the { changed: nodeBody }
.
Based on explanations from sources like this and this, it seems that the curly braces are being used to define an object literal as a way to pass key/value pairs as function arguments. However, in this case, it's being used as a parameter. If this construct indeed creates an object, my understanding is that changed
would be the property name and nodeBody
would be its value. But how is this object assigned to a variable and how can it be referenced within the method body?
Adding to my confusion is the fact that only nodeBody
is utilized in the return statement. So why isn't it simply used as a single parameter right away?
What exactly is the purpose or benefit of using this particular input format?