Jasonette / Jasonette/JASONETTE-iOS
Add "events" field to components
- Dominant language
- JavaScript
- Stars
- 5.2k
- Forks
- 347
- PR merge metrics
- No merged PRs in 30d
Description
This is an enhancement to Jason to accommodate a more powerful event system.
The current system allows you to respond to only a default `event` which is quite limiting.
What I propose is to add an `events` field. This will be an `array` of `events` with their corresponding actions.
This does not supersede the current implementation as the default `action` field will still remain and behave as expected. This new addition will only be for advanced usage.
This enhancement should support existing action mechanisms including `inline actions`, `trigger actions` and `href actions`.
**Spec Considerations**
- Any valid `action` and `href` should can be used to respond to an event
- Event names should use `underscore_case`
- Components should have a list of valid events which will be checked against during and fail if an event is not supported to help in development. This would be nice to have at "compile" (parse) stage, but if implementation would slow down parsing, we can go with doing this at run-time , failing while in `development` mode and reporting them in `production`.
**Examples**
1. Inline Actions
```
{
"type": "label",
"text": "Refresh",
"action": {
"type": "$util.banner",
"options": {
"title": "Default action",
"description": "This is a default action"
}
},
"events": {
"click": {
"type": "$util.banner",
"options": {
"title": "Event action",
"description": "This is an event action"
}
}
}
}
```
2. Trigger Actions
```
{
"type": "label",
"text": "Refresh",
"action": {
"trigger": "refresh_view"
},
"events": {
"click": {
"trigger": "refresh_view"
}
}
}
```
3. Href Actions
```
{
"type": "label",
"text": "Refresh",
"action": {
"href": {
"url": "https://www.twitter.com/gliechtenstein",
"view": "web"
}
},
"events": {
"click": {
"href": {
"url": "https://www.twitter.com/gliechtenstein",
"view": "web"
}
}
}
}
```
4. Multiple events
```
{
"type": "label",
"text": "Refresh",
"events": {
"click": {
"type": "$util.banner",
"options": {
"title": "Event action",
"description": "This is an event action"
}
},
"change": {
"trigger": "refresh_view"
}
}
}
```
If you want fancy a quick laugh, check out https://github.com/CocoaPods/CocoaPods/issues/6158
Contributor guide
Research direction
No files or tests are named in the issue. Start by tracing how components currently process the default action, then review the existing inline, trigger, and href action mechanisms. Done means components accept the proposed events mapping, preserve default actions, support the listed action forms, and validate supported event names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100