How to construct subclasses of Immutable.Record?

爱⌒轻易说出口 提交于 2019-12-01 16:41:34

Immutable.Record "Creates a new Class which produces Record instances.", in other words it's a function in itself which you pass the allowed keys and returns a class you can extend;

class Event extends Immutable.Record({text:'', timestamp:''}) {
  constructor(text) {
    super({text: text, timestamp: Date.now()});
  }
}

> new Event('started').toString()
Event { "text": "started", "timestamp": 1453376445769 }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!