I stumbled upon the following typescript function while inspecting the content metadata component of Alfresco ADF and I can't make sense of it:
private saveNode({ changed: nodeBody }): Observable<Node> {
return this.nodesApiService.updateNode(this.node.id, nodeBody);
}
What I don't understand is the { changed: nodeBody }
.
According to this and this answer, the curly braces are used to denote an object literal as a way to use a key/value pair as a function argument. But here it is used as a parameter. If this creates an object, in my understanding, that would mean that changed
is the name of its property and nodeBody
refers to the properties value. But which variable is this object assigned to and how can you refer to it in the method body?
What confuses me even more is that only nodeBody
is used in the return statement. Then why isn't it used right away as a single parameter?
What is the benefit or use-case of this form of input?