官术网_书友最值得收藏!

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;
主站蜘蛛池模板: 名山县| 永德县| 社旗县| 兴文县| 阳信县| 贺州市| 石河子市| 腾冲县| 苏州市| 弥渡县| 称多县| 福清市| 盐亭县| 盖州市| 宜宾市| 芷江| 白山市| 本溪| 库车县| 廊坊市| 尉犁县| 芦山县| 新昌县| 霍州市| 雅江县| 义马市| 山西省| 观塘区| 海丰县| 德保县| 达尔| 龙口市| 沙雅县| 铁岭县| 合川市| 靖边县| 翁牛特旗| 周口市| 鹤峰县| 大化| 涿鹿县|