- Advanced TypeScript Programming Projects
- Peter O'Hanlon
- 169字
- 2021-06-24 13:27:14
Adding active record support to our state
Before we look at our actual database code, we need to introduce one last piece of the puzzle—the object that we are going to store. While we have been working with state, we have been using IPersonState to represent the state of a person and, as far as the PersonalDetails component goes, that is sufficient. While working with the database, we want to expand this state. We are going to introduce a new IsActive parameter that will determine whether a person is shown on the screen. We don't need to change the implementation of IPersonState to add this capability; we are going to use an intersection type to handle this instead. The first thing we have to do is add a class that has this active flag and then create our intersection type:
export interface IRecordState {
IsActive : boolean;
}
export class RecordState implements IRecordState {
public IsActive: boolean;
}
export type PersonRecord = RecordState & IPersonState;
推薦閱讀
- 電腦組裝與系統(tǒng)安裝
- Linux網(wǎng)絡(luò)管理與配置(第2版)
- 構(gòu)建高可用Linux服務(wù)器(第4版)
- Implementing Cisco UCS Solutions
- Arch Linux Environment Setup How-to
- Kali Linux滲透測試全流程詳解
- Windows Phone 8 Application Development Essentials
- 注冊表應(yīng)用完全DIY
- Python UNIX和Linux系統(tǒng)管理指南
- Hadoop Real-World Solutions Cookbook
- Linux應(yīng)用大全 基礎(chǔ)與管理
- OpenHarmony開發(fā)與實(shí)踐:基于紅莓RK2206開發(fā)板
- OpenStack Essentials(Second Edition)
- 每天5分鐘玩轉(zhuǎn)Docker容器技術(shù)
- 微軟360度