lundi 20 août 2018

ember evented on error: Assertion Failed: on called without valid event names

i have a controller in my ember 2.18 app and i want to make it listen to some event 'myEventName' triggered somewhere in the app, to change the model properties.

according to the API docs for this version the way to catch an emitted event is like this:

import Evented from '@ember/object/evented';
import Controller from '@ember/controller';
// extend some object, like a Controller
const myExtendedObject = Controller.extend(Evented, { 
    // stuff ...
     });

myExtendedObject.on('myEventName', function (args) {  
    console.log("catch importDone  ok", args); 
    });
export default myExtendedObject;

the code compiles well with ember build dev, but in the browser's JS console i get this error message:

Error: Assertion Failed: on called without valid event names error.js:40

i tried renaming event, but i cannot find why the event name is wrong. also tried to set 3 arguments to the "on" method, but it is still bugging with the event name. what am i missing ?




Aucun commentaire:

Enregistrer un commentaire