adopted-ember-addons / adopted-ember-addons/ember-set-helper

Documentation around setting nested keys

未关闭
#31 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
69
派生
9
PR 合并指标
30 天内没有已合并 PR

描述

Have just spent about an hour trying to convert this:
```oninput={{action (mut this.creativeForForm.shareContent.shareCommentary.text) value="target.value"}}```

into this:
```{{on "input" (pick "target.value" (set this "creativeForForm.shareContent.shareCommentary.text"))}}```

I would have expected this to work per your docs, since the format generally appears to be `set thisContext "path" newValue`, though after a while it apparent that no examples of nested paths are actually provided in the docs. It says `dynamic paths can be provided`, but still sticks to the syntax of `set thisContext pathExpressedAsVariable`.

Eventually through trial and error, I discovered that
``` {{on "input" (pick "target.value" (set this.creativeForForm.shareContent.shareCommentary.text))}}```

works, although this is not documented at all (but is the same format as `mut` but this style isn't mentioned once in the docs). Given your API for everything else, I even would have expected
``` {{on "input" (pick "target.value" (set this.creativeForForm.shareContent.shareCommentary "text"))}}```
over the one that actually ended up working.

Would appreciate a callout added to the docs on how exactly setting nested paths should be achieved then as I don't want to be using an undocumented method if this is not stable. Thanks!

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。