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

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;
主站蜘蛛池模板: 黄山市| 栖霞市| 大竹县| 天峻县| 安陆市| 资中县| 万山特区| 张家口市| 桦川县| 修武县| 长乐市| 枣庄市| 安溪县| 嘉定区| 秦皇岛市| 香河县| 昌吉市| 乌什县| 射洪县| 黄平县| 青岛市| 邯郸市| 开江县| 衡阳市| 慈溪市| 兴海县| 鄢陵县| 通州区| 松溪县| 彰化县| 大洼县| 巧家县| 定陶县| 雅江县| 铁岭县| 福清市| 利津县| 冷水江市| 临沭县| 怀化市| 囊谦县|