Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation around setting nested keys #31

Open
brokenalarms opened this issue Mar 8, 2021 · 1 comment
Open

Documentation around setting nested keys #31

brokenalarms opened this issue Mar 8, 2021 · 1 comment

Comments

@brokenalarms
Copy link

brokenalarms commented Mar 8, 2021

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!

@brokenalarms
Copy link
Author

In fact if you follow your documentation to do set this 'path' value it actually gives an error in the build, the (set) helper can only recieve 2 arguments at most, recieved: 3l. (received)

...all the examples have 3 arguments :) It seems like the documentation needs updating generally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant