ngRX --selector 结构分析

101 阅读1分钟

一起养成写作习惯!这是我参与「掘金日新计划 · 4 月更文挑战」的第14天,点击查看活动详情

1,seletor 是一个纯函数

2, 语法例子

const getProducts = (state) => state.products; const getPizzas = (state) => state.pizzas; 
const getEntities = (state) => state.entities;

3, 虚拟例子

class Store {
    constructor() {
      this.state = {
        products: {
          pizzas: {
            entities: {
              1: { name: 'Pizza 1', id: 1 },
              2: { name: 'Pizza 2', id: 2 },
            },
          },
        },
      };
    }
  }