Guest User

Untitled

a guest
Dec 15th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import ArrayProxy from 'ember-controller/proxy'
  2. import firebase from 'firebase'
  3. import _ from 'npm:lodash'
  4.  
  5.  
  6.  
  7. export default ArrayProxy.extend({
  8. ref: null,
  9.  
  10. init () {
  11. this.set('ref', firebase.database().ref('courses').limitToLast(10))
  12.  
  13. return this
  14. },
  15.  
  16. loadContent: function () {
  17. this.ref.on('value', snapshot => {
  18. const courses = _.map(snapshot.val(), (value, key) => {
  19. value.id = key
  20. return value
  21. })
  22.  
  23. this.set('content', courses)
  24. })
  25. }.observes('ref')
  26. })
Add Comment
Please, Sign In to add comment