First thing first, let's define a action to update entity:

import { createAction, props } from "@ngrx/store";
import { Update } from "@ngrx/entity";
import { Course } from "./model/course"; export const courseUpdated = createAction(
"[Edit Course Dialog] Course Updated",
props<{ update: Update<Course> }>()
);

The 'Update' interface has props: 'id, changes'.

Component usage:

  onSave() {
const course: Course = {
...this.course,
...this.form.value
}; const update: Update<Course> = {
id: course.id,
changes: course
}; this.store.dispatch(courseUpdated({ update })); this.dialogRef.close();
}

Reducer:

export const coursesReducer = createReducer(
initCoursesState, on(CoursesAction.courseUpdated, (state, action) =>
adapter.updateOne(action.update, state)
)
);

Effect:

  saveCourse$ = createEffect(
() =>
this.action$.pipe(
ofType(CoursesAction.courseUpdated),
concatMap(action =>
this.coursesHttpService.saveCourse(
action.update.id,
action.update.changes
)
)
),
{ dispatch: false }
);

[NgRx] Optimistically Editing Entity Data的更多相关文章

  1. Entity Framework的核心 – EDM(Entity Data Model) 一

    http://blog.csdn.net/wangyongxia921/article/details/42061695 一.EnityFramework EnityFramework的全程是ADO. ...

  2. EF,ADO.NET Entity Data Model简要的笔记

    1. 新建一个项目,添加一个ADO.NET Entity Data Model的文件,此文件会生成所有的数据对象模型,如果是用vs2012生的话,在.Designer.cs里会出现“// Defaul ...

  3. Create Entity Data Model

    http://www.entityframeworktutorial.net/EntityFramework5/create-dbcontext-in-entity-framework5.aspx 官 ...

  4. Entity Framework Tutorial Basics(5):Create Entity Data Model

    Create Entity Data Model: Here, we are going to create an Entity Data Model (EDM) for SchoolDB datab ...

  5. 关于VS2010“ADO.NET Entity Data Model模板丢失或者添加失败问题

    我最近在安装vs2010后,添加ADO.NET Entity 实体时发现,我的新建项里面并没有这个实体模型,后来我就在博问里面发表了问题,请求大家帮忙解决,悲剧的是少有人回应啊,呵呵,不过我还是在网上 ...

  6. [Angular] Improve Server Communication in Ngrx Effects with NX Data Persistence in Angular

    Communicating with a remote server via HTTP presents an extra level of complexity as there is an inc ...

  7. EntityFramework 学习 一 创建实体数据模型 Create Entity Data Model

    1.用vs2012创建控制台程序 2.设置项目的.net 版本 3.创建Ado.net实体数据模型 3.打开实体数据模型向导Entity Framework有四种模型选择 来自数据库的EF设计器(Da ...

  8. 创建实体数据模型【Create Entity Data Model】(EF基础系列5)

    现在我要来为上面一节末尾给出的数据库(SchoolDB)创建实体数据模型: SchoolDB数据库的脚本我已经写好了,如下: USE master GO IF EXISTS(SELECT * FROM ...

  9. VS2010中没有ado.net entity data model实体数据模型这一选项-解决办法

    前提先安装VS2010 SP1包. 解决办法: 1.从VS2010的安装盘目录下面的WCU\EFTools找到ADONETEntityFrameworkTools_chs.msi和ADONETEnti ...

随机推荐

  1. python基础 — Mysql Server

    sql server对于字符类型的有:char:固定长度,存储ANSI字符,不足的补英文半角空格.nchar:固定长度,存储Unicode字符,不足的补英文半角空格varchar:可变长度,存储ANS ...

  2. HTML常用技巧

    1. 为网页链接添加快捷键:accesskey 属性 https://zhidao.baidu.com/question/2267343500557447508.html 2. 键盘事件设置快捷键:h ...

  3. DFS解决八皇后问题

    2019-07-29 16:49:15 #include <bits/stdc++.h> using namespace std; ][]; int tot; int check(int ...

  4. easyui-datagrid 假分页

    假分页就是将数据一下全查出来,利用前端来把所有数据进行分页

  5. .net core使用ocelot---第三篇 日志记录

    简介 .net core使用ocelot---第一篇 简单使用 .net core使用ocelot---第二篇 身份验证使用 上篇介绍使用asp.net core 创建API网关.本文将介绍Ocelo ...

  6. Java调用WebService方法总结(8)--soap.jar调用WebService

    Apache的soap.jar是一种历史很久远的WebService技术,大概是2001年左右的技术,所需soap.jar可以在http://archive.apache.org/dist/ws/so ...

  7. js数据类型及判断数据类型

    众所周知,js有7种数据类型 1. null 2. undefined 3. boolean 4. number 5. string 6. 引用类型(object.array.function) 7. ...

  8. 第五周(web,machine learning笔记)

    2019/11/2 1.    表现层状态转换(REST, representational state transfer.)一种万维网软件架构风格,目的是便于不同软件/程序在网络(例如互联网)中互相 ...

  9. Angular应用架构设计-3:Ngrx Store

    这是有关Angular应用架构设计系列文章中的一篇,在这个系列当中,我会结合这近两年中对Angular.Ionic.甚至Vuejs等框架的使用经验,总结在应用设计和开发过程中遇到的问题.和总结的经验, ...

  10. TypeScript_基础数据类型

    TypeScript 的基础数据类型包含: string.number.boolean.array .object.null.undefined.enmu.void.never.any.tuple 注 ...