Last active
October 5, 2017 08:30
-
-
Save kkenan/ae70af065b822d1528daf8b30e45f259 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { | |
computed | |
} = Ember; | |
export default Ember.Object.extend({ | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import BaseModel from './base'; | |
const { | |
computed | |
} = Ember; | |
export default BaseModel.extend({ | |
// Example of computed properties | |
fullName: computed('firstName', 'lastName', function () { | |
return this.get('firstName') + ' ' + this.get('lastName'); | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('user-route'); | |
}); | |
export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { | |
inject: { | |
service | |
} | |
} = Ember; | |
export default Ember.Route.extend({ | |
userService: service('user-service'), | |
model: function () { | |
return this.get('userService').getCurrentUser(); | |
}, | |
actions: { | |
onLogin: function (usernmae, password) { | |
this.get('userService').login(username, password) | |
.then(() => this.transitionTo('/')) | |
.catch(() => this.transitionTo('/error')); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
ajax: function (url, params) { | |
const data = Object.assign({ | |
url | |
}, params || {}); | |
return Ember.$.ajax(data); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
// currentUser: null, | |
// getCurrentUser()... | |
// setCurrentUser() | |
// window.bootstrap.currentUser | |
}); | |
// ember-initializers | |
// -- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BaseService from './base-service'; | |
import UserModel from '../models/user'; | |
export default BaseService.extend({ | |
getCurrentUser: function () { | |
return this.ajax('/api/v1/users/current') | |
.then(createUserModel); | |
} | |
// Rest of the methods | |
}); | |
function createUserModel(params) { | |
return UserModel.create(params); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.12.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment