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

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;
主站蜘蛛池模板: 五大连池市| 罗源县| 安多县| 永平县| 彭州市| 敦化市| 张家港市| 正蓝旗| 清徐县| 仙游县| 高陵县| 德化县| 壤塘县| 邢台市| 项城市| 张家川| 大悟县| 高要市| 广德县| 平凉市| 惠东县| 湘潭县| 富源县| 伽师县| 墨江| 威宁| 扶余县| 胶州市| 霍山县| 富锦市| 海宁市| 黑龙江省| 团风县| 永安市| 台东市| 高雄县| 重庆市| 壤塘县| 商城县| 读书| 普安县|