pangratz prattles

GitHub Dashboard #7

Jul23rd, 20125:53 pm

Goal of this iteration: Use DS.Store

Alight, so know is the time to use DS.Store to add even more ember-data awesomeness. First of all let’s change the Dashboard.GitHubDataSource to extend a DS.Adapter so it can be used as data source for a DS.Store. Next: create a store under the Dashboard namespace, which uses this very adapter:

Alright, everything is set up to be used in the router, so instead of manually creating a Dashboard.GitHubDataSource and invoking loadWatchedRepositories on the repositoriesController, we use the store instead. The updated root.user route on the router looks like this:

12345678910111213141516171819

user:Ember.Route.extend({route:'/:username',connectOutlets:function(router,context){varstore=router.get('store');// get watched repositories for given usernamevarwatchedRepositories=store.findQuery(Dashboard.Repository,{username:context.username,type:'watched'});// set watched repositories on repositoriesControllervarrepositoriesController=router.get('repositoriesController');repositoriesController.set('content',watchedRepositories);// connect with repositoriesController & RepositoriesViewrouter.get('applicationController').connectOutlet('repositories');}})

Roundup

Great, the dashboard is now officially DS.Store-ified. Booyakasha. Everything is nicely decoupled and in it’s place. One thing that still bothers me though is the adapter: Dashboard.GitHubDataSource.create() in the Dashboard.Store definition. At this time of writing I haven’t found an elegant way around this problem. Do you know one?

UPDATE: It will be possible soon to specify a class as adapter, see commit 8a6e33f which will be available when the relationship-improvements branch is merged.