Jasonette / Jasonette/documentation

Clarify inline action vs regsitry based trigger gotcha

Open
#71 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
120
Forks
72
PR merge metrics
No merged PRs in 30d

Description

In most cases, defining actions under `$jason.head.actions` and calling them via `trigger` is recommended.

This is because if we ever happen to pass around dynamic arguments, these template expressions may get instantiated on view render and will baked into the view.

For example, in the following case we want to display an alert with the local variable `val` at the time of user tap.

```
{
"type": "label",
"text": "push",
"action": {
"type": "$util.alert",
"options": {
"title": "value",
"description": "{{$get.val}}"
}
}
}
```

However what actually happens is: this will get rendered at load time **with the `val` value at the time of render**. Then this action is not dynamic anymore because all its arguments have been instantiated. This is why it's recommended that you put all actions under `head.actions` so that these don't get instantiated at view render.

But this point can be confusing for people new to the framework.

So this issue is for figuring out how to deal with this problem. Could be through better documentation, could be through some sort of warning messages, something else, or all of the above.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the inline action example using `$jason.head.actions`, `trigger`, and `{{$get.val}}`; the issue provides no repository files or tests to inspect. Done means establishing and documenting how render-time and tap-time arguments should behave, or defining another concrete way to prevent newcomers from confusing the two.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.