-
Notifications
You must be signed in to change notification settings - Fork 48
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
Remove action bubbling #61
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,38 +7,20 @@ Demo: http://jsbin.com/jipani/edit?html,js,output | |
ember install ember-route-action-helper | ||
``` | ||
|
||
The `route-action` helper allows you to bubble closure actions, which will delegate it to the currently active route hierarchy per the bubbling rules explained under `actions`. Like closure actions, `route-action` will also have a return value. | ||
The `route-action` helper allows you to call actions from routes. Like closure actions, `route-action` will also have a return value. | ||
|
||
However, returning `true` in an action will **not** preserve bubbling semantics. In case you would like that behavior, you should use ordinary string actions instead. | ||
Route actions do not bubble. In case you would like that behavior, you should use ordinary string actions instead. | ||
|
||
## Usage | ||
|
||
For example, this route template tells the component to lookup the `updateFoo` action on the route when its internal `clicked` property is invoked, and curries the function call with 2 arguments. | ||
For example, this route template tells the component to lookup the `updateFoo` action on the current route when its internal `clicked` property is invoked, and curries the function call with 2 arguments. | ||
|
||
```hbs | ||
{{! foo/route.hbs }} | ||
{{foo-bar clicked=(route-action "updateFoo" "Hello" "world")}} | ||
``` | ||
|
||
If the action is not found on the current route, it is bubbled up: | ||
|
||
```js | ||
// application/route.js | ||
import Ember from 'ember'; | ||
|
||
const { Route, set } = Ember; | ||
|
||
export default Route.extend({ | ||
actions: { | ||
updateFoo(...args) { | ||
// handle action | ||
return 42; | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
If no action is found after bubbling, an error will be raised. The `route-action` also has a return value: | ||
If no action is found, an error will be raised. The `route-action` also has a return value: | ||
|
||
```js | ||
// foo/component.js | ||
|
@@ -65,7 +47,7 @@ You may also use in conjunction with the `{{action}}` helper: | |
|
||
## Compatibility | ||
|
||
This addon will work on Ember versions `1.13.x` and up only, due to use of the new `Helper` implementation. | ||
This addon will work on Ember versions `2.x` and up only. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are going for "breaking changes" maybe we can just say 2.4? |
||
|
||
## Installation | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @ts-nocheck | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this do? |
||
import Ember from 'ember'; | ||
|
||
let ClosureActionModule; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Ember from 'ember'; | ||
|
||
const { Component } = Ember; | ||
|
||
export default Component.extend({ | ||
baseValue: 4, | ||
value: null, | ||
actions: { | ||
addValue(x) { | ||
this.set('value', this.get('add')(x)); | ||
} | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from 'ember'; | ||
|
||
const { Component } = Ember; | ||
|
||
export default Component.extend({ | ||
value: null, | ||
actions: { | ||
confirm() { | ||
this.set('value', this.get('doAction')()); | ||
} | ||
} | ||
}); |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to say "found in the current route"?