gavinjoyce / ember-component-inbound-actions Goto Github PK
View Code? Open in Web Editor NEWSend actions to Ember.js components
License: MIT License
Send actions to Ember.js components
License: MIT License
Hi, this is probably my mistake but couldn't get it to work. Whenever I do this.get('nameForm').send('something')
, I get Cannot read property 'send' of undefined
.
I can inspect the actionReciever property on my component but see no nameForm on my controller. What did I miss?
// index.hbs
{{ember-youtube title=model.title actionReciever=nameForm}}
// components/my-component.js
import InboundActions from 'ember-component-inbound-actions/inbound-actions';
export default Ember.Component.extend(InboundActions, {
I'm in a situation where I need to get the return value of a call to an action (in my case a Promise). Basically I'd like to call the action similar as how you'd call a closure action.
Now I have to resort to something hacky like:
const childComponent = this.get('childComponent').target;
return childComponent.actions.someAction.call(childComponent);
whereas ideally I'd do something like
return this.get('childComponent.someAction')();
Is this something that you've thought about extending the addon with? I know that Ember.ActionHandler
only exposes the send
function. I'm not too familiar with the part of Ember.js that implements closure actions but maybe there's a way we could easily mix in that functionality similar to Ember.ActionHandler
. Just wanted to get your opinion before I dive into this further :-).
Mind releasing #20?
can this can be used in controller init function,
how ?
Have a component like this:
my-component.js
import Ember from 'ember';
import InboundActions from 'ember-component-inbound-actions/inbound-actions';
export default Ember.Component.extend(InboundActions, {
concatenatedProperties: ['x'],
x: ['A'],
classNames: ['A'],
});
my-component.hbs
And use it like this:
application.hbs
Then the rendered result will be this:
without binding the actionReceiver
x: A,B
classNames: A,B
with binding the actionReceiver
x: B
classNames: B
That is, binding the the actionReceiver to the outer context causes the concatenatedProperties to not work.
Twiddle demonstrating the error:
https://ember-twiddle.com/c7842938c40eb9118db2a45e8f4f1292
Hi,
first of all: thanks for this addon! ๐
I'm working on an addon that does form validations based on contextual components, and I'd like to implement a "reset" action that broadcasts an "reset" event from the form to all it's children. However, it seems that only the last child receives the event - I've set up a twiddle that should demonstrate this.
Did i miss something, or is it harder than expected to get this to work?
Thanks in advance!
Hi, having trouble making this approach work with Ember 1.13. Tried to build a similar approach here with two test cases:
http://stackoverflow.com/questions/30274097/sending-actions-to-a-component-with-ember-js-1-13
What versions is https://github.com/GavinJoyce/ember-component-inbound-actions/blob/master/addon/inbound-actions.js#L4 supposed to detect? It matches every ember 2.x version, only fails less than 1.13. Is that desired?
Hi,
I'm developing an addon that is dependent on ember-component-inbound-actions
so I am relying on PR #12 (#12) as I don't want prototype extensions enabled in my addon. However, the latest release 0.0.4 does not incorporate this PR. I can point to a specific commit in my package.json
but that is not so clean.
Would it be possible to release a new version that includes the latest PRs?
Thanks!
I've just recently resolved this same deprecation in another addon simply by upgrading ember, and found this one now as well.
DEPRECATION: An addon is trying to access project.nodeModulesPath. This is not a reliable way to discover npm modules. Instead, consider doing: require("resolve").sync(something, { basedir: project.root }). Accessed from: new NPMDependencyVersionChecker (/home/skidder/dev/brokermate/node_modules/ember-component-inbound-actions/node_modules/ember-cli-version-checker/src/npm-dependency-version-checker.js:11:33)
Given that this requires setting actionReceiver, how would you make this work when the component is repeated in an each block and you want the event to go to a specific instance of the component?
Is the license included with the project MIT?
Could you release a new version containing #29, so we can get rid of the annoying babel deprecation warning?
I'm writing a unit test around a component that uses InboundActions
and getting the following error:
Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run
To isolate this to InboundActions
, I've eliminated all code in the component. At this point here are the files:
// app/components/bogus-component/component.js
import Component from '@ember/component';
import InboundActions from 'ember-component-inbound-actions/inbound-actions';
export default Component.extend(InboundActions, { });
// tests/unit/component/bogus-component/component-test.js
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Component | bogus-component', function(hooks) {
setupTest(hooks);
test('unfiltered', function(assert) {
this.owner.factoryFor('component:bogus-component').create({});
assert.ok(true);
});
});
Version deets:
"ember-cli": "~3.2.0",
"ember-component-inbound-actions": "^1.3.0",
Let me know if you need anything else.
I don't know if this is expected behavior, but it doesn't "feel" correct.
The behavior that we observe is that components which use this plugin do immediately rerender after being rendered. I created a reproducible case here: https://github.com/Maarius/action-receiver-test
To create the repo I did the following steps:
ember new ..
ember install ember-component-inbound-actions
ember g component action-receiver --pod
application.hbs
You can now see in the console that when the component is added using {{action-receiver}}
, we see the normal logging of the lifecycle events.
However, when the component is added like {{action-receiver actionReceiver=nameForm}}
, we see that immediately after going through the lifecycle events, a rerender happens.
Is that behavior expected? Is there a way to have the component do not rerender immediately?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.