Skip to content

Instantly share code, notes, and snippets.

@pavloo
Created June 23, 2014 16:08
Show Gist options
  • Save pavloo/611ff132719a3903d232 to your computer and use it in GitHub Desktop.
Save pavloo/611ff132719a3903d232 to your computer and use it in GitHub Desktop.
initialize: (container, application)->
sharedStore = Ember.Object.create()
auth = Ember.Object.extend
token: null
currentUser: (->
result = application.LoginLogic.retrieveCurrentUser(@get('token'))
if result
store = container.lookup('store:main')
store.createRecord('user', result)
else
null
).property('token')
sharedStore.set('auth', auth.create())
container.optionsForType('globals', {instantiate: false, singleton: true})
container.register('globals:shared', sharedStore)
container.typeInjection('controller', 'shared', 'globals:shared')
container.typeInjection('route', 'shared', 'globals:shared')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment