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

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;
主站蜘蛛池模板: 耿马| 房产| 屏东县| 新竹市| 乌拉特前旗| 大邑县| 中阳县| 抚远县| 会理县| 封开县| 甘泉县| 白银市| 曲松县| 福清市| 福鼎市| 五寨县| 凤山县| 汤原县| 高州市| 石林| 封开县| 新野县| 加查县| 林芝县| 吕梁市| 汤阴县| 武川县| 绩溪县| 厦门市| 永定县| 沾化县| 铅山县| 理塘县| 葵青区| 舒城县| 宜昌市| 迁安市| 绥芬河市| 肇州县| 龙江县| 东阳市|