我尝试使用Angular原理图,并在各个地方遇到了函数branchAndMerge()。然而,没有人解释它的作用。
我见过的地方:
澄清它与merge / mergeWith的区别,以及如何正确使用它将不胜感激。
P.S:合并在@angular-devkit/schematics解释如下:
将输入树与其他树合并。
顺便说一下,我认为merge()现在是mergeWith,尽管我并不是100%肯定。
代码示例
const rule =
// Creates a new rule that is a concatenation of other rules.
chain([
// Everyone uses it, but no one explains what it does...
branchAndMerge(
chain([
// Merges the project tree with the virtual tree
mergeWith(virtualTree)
]))
]);
答案 0 :(得分:2)
以下video提供了到目前为止我所听到的最好的解释:
从当前树分支,该树是基于虚拟文件系统的 在当前目录之外
如果有人要研究code in the repo,就会发现确实如此。我想这样做的好处是出于性能方面的考虑,其中它允许人们修改键/值而不是实际的硬盘。另外,我想它还会简化过程,因为它使位置无关紧要,这会使原理图的过程大大复杂化。