Updated to AngularFire2 v5.0.

One important change is that you need to call .snapshotChanges() or .valueChanges() to get data as Observable back.

    return this.db.list<Skill>(`skills/${this.uid}`)
.snapshotChanges()

The problem is when there is no data, .snapshotChanges() never emit a value.

Luckly it is Observable, we can solve the problem by using .startWith():

  getSkills(): Observable<Skill[]> {
return this.db.list<Skill>(`skills/${this.uid}`)
.snapshotChanges()
.startWith([])
.map((actions) =>
actions.map((action) => ({$key: action.key, ...action.payload.val()}))
);
}

If there is no data coming back from firebase, we still emit a empty array. This is much friendly if you work with Ngrx. Because if you depends on .snapshotChange() to emit a value back to switch map to next action, it might just block there, and your next action will never get dispatched.

最新文章

  1. position: fixed用在iframe里面失效了
  2. 【转】ubuntu vpn自动切换路由
  3. js读书笔记
  4. 反射 + 抽象工厂模式切换DB数据源(附Demo)
  5. C#线程并发执行的实例[转]
  6. c# 调用分页(控制器端的)与时间的格式
  7. 气象API(2)
  8. Spring3 整合Hibernate3.5 动态切换SessionFactory (切换数据库方言)
  9. java连接mysql批量写入数据
  10. Javascript教程:AngularJS的五个超酷特性
  11. iis7如何取消目录的可执行权限
  12. PureMVC(JS版)源码解析(三):Observer类
  13. noip201506 Message 信息传递
  14. 第四节 mount /who / mkdir /rmdir /rm /cp /mv /touch /cat /tac/head /tail /more /less / chmod /chown /umask /chattr /lsattr /history /echo
  15. Linux显示版本信息并退出
  16. WebSocket整合SSM(Spring,Struts2,Maven)
  17. windows系统dokuwiki安装部署设置 xampp环境配置
  18. AndroidStudio中如何使用GsonFormat
  19. java web(三):ServletContext、session、ServletConfig、request、response对象
  20. SimpleDateFormat的parse(String str)方法的用法

热门文章

  1. Shell应用之网卡流量监测
  2. linux Cenos-7.0下安装jdk搭建环境变量
  3. 洛谷——P1019 单词接龙(NOIP2000 T3)
  4. Service绑定模式
  5. POJ 3070 Fibonacci 矩阵高速求法
  6. Unity 之 C# 利用回调函数实现C++匿名函数
  7. iOS xib View宽高不能改变
  8. vue6 发请求
  9. caioj1441:第k小的数Ⅰ
  10. javaScript 三目运算符初探