-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Where should i put Class reopens when something uses them as configuration? #676
Comments
Our official docs show how to build an initializer. Maybe @rjackson has some tips based on how class reopening is handled in es6 ember. |
@MajorBreakfast i know this isn't a bug but it would be nice to have a proper way to do this, and docs. Thanks for the reply. |
Our initializer docs seem fine, here is how it could look like for your case: // app/initializers/simple-auth.js
export default {
name: 'simple-auth-configuration',
initialize: function() {
Ember.SimpleAuth.Authenticators.Devise.reopen({ // Devise -> Device?
serverTokenEndpoint: 'http://localhost:3000/api/v1/tokens'
});
}
}; No docs on class reopening though. It would be nice to have a pattern. I'm not sure, though, how class reopening fits together with modules. It's not side effect free. |
Yeah maybe i wasn't clear sorry about that, i knew how to do the initializer, sorry that wasn't an issue. Your example is exactly what i was thinking, so i think id start with that for now. Thanks a ton! I agree having a actual prescribed convention / pattern, would be really nice. |
I'm struggling looking for the right pattern for class reopens too. I'm trying to inject my Model specific pushers extend the pusher class to add specific event names and utilize hooks. During object initialization, an assertion in made to ensure that socket and store are present. UPDATE: the es6 pattern below does work, I just needed to position my initializer for session to happen after the initializer for store within the ember-cli pattern, I got away with leaving that off before, still looking for thoughts on best pattern. Global Pattern
ES6 Pattern /initializers/pusher.js
/initializers/start-pushers.js
|
Pusher.reopen({
store : container.lookup('store:main'),
socket : container.lookup('socket:main')
}); should just be injection rules, which isn't possible because you are bypassing it. |
That's what I was doing for the globals based version of the app (which worked) before converting it to ember-cli and es6. |
I am running into a problem with ember-simple-auth.
It is unclear when using ES6 modules where to put class reopens.
Basically i have:
The only place i can put that and have it work is app.js is there any pattern for this to load this type of stuff via a separate configuration module?
It seems like an initializer would be the right place but theres no documentation on how that would work, for an initializer do i just need a to return a function or an object that would bootstrap this code?
The text was updated successfully, but these errors were encountered: