I am trying to figure out how to convert an existing initializer to the newer instanceInitializer/initializer format that is in Ember 1.11+ (http://ift.tt/1B0z5ED)
Here is my existing initializer:
app/initializers/session.coffee (ps this is to stick the logged in user onto the client session using ember-simple-auth)
import Ember from 'ember'
import Session from 'simple-auth/session'
UserSession = Session.extend
# Here we set the 'session.context' property which is used for
# filtering the User contexts throughout the site.
context: (->
user = @get 'user'
# Check for a defaultContext and use that otherwise use empty.
if user and user.defaultContext
@container.lookup('store:main')
.find('context', user.defaultContext)
.then (context)=>
@set 'context', context
else
@container.lookup('store:main').createRecord 'context'
).property 'user'
# Takes two parameters: container and app
initialize = (container, app) ->
container.register 'session:usersession', UserSession
UserSessionInitializer =
name: 'session'
before: 'simple-auth'
initialize: initialize
export default UserSessionInitializer
So I tried to split out the UserSession
stuff which contains the @container.lookup into app/instance-initializers/session.coffee but then I need to import it in the initializer/session.coffee because the container.register uses UserSession
Any help on how this should work is appreciated!
Thanks
Aucun commentaire:
Enregistrer un commentaire