ember-events-modifier

eventing modifiers

Usage no npm install needed!

<script type="module">
  import emberEventsModifier from 'https://cdn.skypack.dev/ember-events-modifier';
</script>

README

ember-events-modifier

NPM Build Status Ember Observer Score Ember Version Download count Code Climate Test Coverage

Installation

ember install ember-events-modifier

Demo

Demo

Usage

The addon provides an events service which can be used to facilitate events throughout your application. You can use the service directly, without using the modifiers, described below.

import Controller from "@ember/controller";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";

export default class MyController extends Controller {
    @service events;

    @action clickedBook(book) {
        this.events.trigger(`book:active:${book.id}`, book);
    }
}

on-event

The on-event modifier allows you to register a handler for specific events.

Your action handler will be passed arguments that are provided when the action is triggered.

Note that the handler is automatically registered and removed on insertion/removal, respectively.

<div {{on-event "blog-updated" this.reloadBlog}}>
    ...
</div>

trigger-event

The trigger-event modifier allows you to trigger an event when the element is inserted.

{{#if this.showDetails}}
    <div {{trigger-event (concat "book:showing-details:" @book.id) @book}}>
        ...
    </div>
{{/if}}

Compatibility

  • Ember.js v3.20 or above
  • Node.js v12 or above

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.