Giter Club home page Giter Club logo

Comments (2)

GavinJoyce avatar GavinJoyce commented on July 19, 2024

It sounds like you could use contextual components and closure actions. Is there any reason why you couldn't? I'm interested as I suspect that this addon might not have any use cases that aren't covered by core Ember primitives

from ember-component-inbound-actions.

YoranBrondsema avatar YoranBrondsema commented on July 19, 2024

Maybe my use case will make it clearer. I want to delay the destroy of a component, for animation purposes. Ideally Ember would have a sort of an async willDestroyElement, similar to how the model hook in a route is blocking. Reality is different :-).

So I'm using ember-component-inbound-actions to send an action willClose to the child component, which returns a Promise. The parent component then waits until this Promise resolves to effectively destroy the child component.

Something like this:

component:parent-component

// components/parent-component/template.hbs
{{#if showChildComponent}}
  {{child-component actionReceiver=childComponent}}
{{/if}}
// components/parent-component/component.js
...
hideChildComponent() {
  const childComponent = this.get('childComponent').target;      
  childComponent.actions.willClose.call(childComponent).then(() => {
    this.set('showChildComponent', false);
  });
}
...

component:child-component

// components/child-component/component.js
...
actions: {
  willClose() {
    return this.someAsyncStuffThatReturnsAPromise();
  }
}
...

It's hacky I agree but it's the easiest solution I could come up with.

So now the addon allows us to perform a send on an action receiver. However, it doesn't give us the return value of the action. I hope this makes it a bit clearer?

from ember-component-inbound-actions.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.