Skip to content
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

[metal-events] Document process to emit events #308

Closed
jonathantneal opened this issue Nov 21, 2017 · 4 comments
Closed

[metal-events] Document process to emit events #308

jonathantneal opened this issue Nov 21, 2017 · 4 comments

Comments

@jonathantneal
Copy link

I’m unsure how to emit events when working with metal.

In my case, I would like to emit events from metal-toggler whenever the component expands or collapses. How might I do this? I could not find emit documentation

@pragmaticivan
Copy link
Contributor

hey @jonathantneal thanks,

Just in case if that helps you while that gets documented : https://github.com/metal/metal-training

@robframpton
Copy link

Hey @jonathantneal

We're currently in the process of improving Metal.js docs, we'll make sure that our improvements include this information. To answer your question, since Component has State in it's prototype chain, it has access to the emit method which allows you to emit custom events with custom payloads.

class MyComponent extends Component {
    someMethod() {
        this.emit('customEventName', {
            key: 'value'
        });
    }
}

Hope that helps.

@jonathantneal
Copy link
Author

Thanks, @pragmaticivan, @Robert-Frampton, that does help. Let me know if I can help with the docs, or at least help review them 😄

@robframpton
Copy link

Moving this over to metaljs.com/issues bryceosterhaus/metaljs.com#86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants