When a Todo property updates, you still must create a new Array of Todos and assign a new reference. This lesson walks you through refactoring from the current approach to the immutable approach. TodoItemRender.ts: import {Component, Input, ViewEncap…
const stores = Immutable.List([ { name: 'Store42', position: { latitude: 61.45, longitude: 23.11, }, address: 'whatever' }, { name: 'Store2', position: { latitude: 61.48, longitude: 23.87 }, address: 'whatever' }, { name: 'Store3', position: { latitu…
Immer is a tiny library that makes it possible to work with immutable data in JavaScript in a much more straight-forward way by operating on a temporarily draft state and using all the normal JavaScript API's and data structures. The first part of th…
From Article: RESOLVING ROUTE DATA IN ANGULAR 2 Github If you know Anuglar UI router, you must know resolve function in ui router, which you can load data before template and controller get inited. In Angular2 router, you can also use resovler. The r…
TL;DR 脏检查是一种模型到视图的数据映射机制,由 $apply 或 $digest 触发. 脏检查的范围是整个页面,不受区域或组件划分影响 使用尽量简单的绑定表达式提升脏检查执行速度 尽量减少页面上绑定表达式的个数(单次绑定和ng-if) 给 ng-repeat 添加 track by 让 angular 复用已有元素 什么是脏数据检查(Dirty checking) Angular 是一个 MVVM 前端框架,提供了双向数据绑定.所谓双向数据绑定(Two-way data binding)…
To demonstrate the difference between mutability and immutability, imagine taking a drink from a glass of water. If our glass is mutable, when we take a drink, we retain the same glass and change the amount of water in that glass. However, if our gla…
Link: https://angular.io/docs/js/latest/api/core/OnInit-interface.html, https://www.youtube.com/watch?v=bY92HFyaBvo export interface OnInit exported from angular2/core defined in angular2/src/core/linker/interfaces.ts (line 79) Implement this interfa…
现状 最近在重构手上的一个 Angular 项目,之前是用的自己写的一个仿 Elm 架构的库来进行的状态管理,期间遇到了这些痛点: 样板代码太多 异步处理太过繁琐 需要单独维护一个 npm 包 其中,一.二两点是促使我重构的原因,第三点是促使我更换状态管理方案的理由(太懒了,根本不想去维护这个项目). 样板代码太多 Elm 架构中,有下面几个重要的概念: Message(在 Redux 中被称作 Action) Update(在 Redux 中被称作 Reducer) Model 这三个概念用…
Immutable.js iterables offer the reduce() method, a powerful and often misunderstood functional operator on which map(), filter(), groupBy(), etc. are built. The concept is simple: reduce transforms your iterable into something else, that's all. The…
Immutable.js offers the fromJS() method to build immutable structures from objects and array. Objects are converted into maps. Arrays are converted into lists. The fromJS() method can also take a reviver function for custom conversions.  Object to Im…