I'm working on porting an Ember.js app over to ember-cli.
My app is an augmented boardgame and, in it, I have an ember-states StateMachine subclass that manages actions that involve passing the game back and forth between two players.
In that subclass, I call reopen() in order to define a method that's bound to the currentState.name of the state machine:
PassManager.reopen({
isPassing : function(){
return this.get("currentState.name") == "pass";
}.property("currentState.name")
});
See in context here: https://github.com/atduskgreg/SneakGame/blob/ember-cli-refactor/app/models/pass-manager.js#L49
I then call that function in an if-statement in my templates:
<h1>Player character assignments</h1>
{{#if PassManager.isPassing}}
{{partial 'pass'}}
{{else}}
<p>You are {{current-player-color}}.</p>
<p><button {{action 'next'}}>Got it</button></p>
{{/if}}
When the PassManager is in the "pass" state this should return true and show the relevant partial and when it's false it should show the rest of the template seen here.
This worked fine before porting to ember-cli, though it did issue a deprecation warning related to this issue: http://emberjs.com/guides/deprecations/#toc_global-lookup-of-views
I've now ported the app to ember-cli and now PassManager.isPassing is no longer evaluated. It always returns false and console.log() statements placed inside it are never executed.
I'm new to working with ES6 modules and was wondering if I'm doing something wrong in how I export PassManager or if there's some more fundamental reason reopen() wouldn't work on an exported module. At the bottom of my pass-manager.js file, I've got:
export default PassManager;
And the PassManager is correctly found in the places I import it in my app. It's just this function defined using reopen() that's not called.