A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/markerikson/project-minimek/commit/42693a331fee1ff73594ff18e3833415655f7262 below:

Use a selector to have only a single Session instance per state update · markerikson/project-minimek@42693a3 · GitHub

File tree Expand file treeCollapse file tree 7 files changed

+22

-12

lines changed

Filter options

Expand file treeCollapse file tree 7 files changed

+22

-12

lines changed Original file line number Diff line number Diff line change

@@ -0,0 +1,10 @@

1 +

import {createSelector} from "reselect";

2 + 3 +

import schema from "app/schema";

4 + 5 +

export const selectEntities = state => state.entities;

6 + 7 +

export const getEntitiesSession = createSelector(

8 +

selectEntities,

9 +

entities => schema.from(entities)

10 +

);

Original file line number Diff line number Diff line change

@@ -2,7 +2,7 @@ import React from "react";

2 2

import {connect} from "react-redux";

3 3

import {Form} from "semantic-ui-react";

4 4 5 -

import schema from "app/schema";

5 +

import {getEntitiesSession} from "features/entities/entitySelectors";

6 6 7 7

import {getWeightClass, selectCurrentMech} from "../mechSelectors";

8 8

@@ -12,7 +12,7 @@ const mapState = (state) => {

12 12 13 13

const currentMech = selectCurrentMech(state);

14 14 15 -

const session = schema.from(state.entities);

15 +

const session = getEntitiesSession(state);

16 16

const {Mech} = session;

17 17 18 18

if(Mech.hasId(currentMech)) {

Original file line number Diff line number Diff line change

@@ -5,14 +5,14 @@ import {Table} from "semantic-ui-react";

5 5

import MechsListHeader from "./MechsListHeader";

6 6

import MechsListRow from "./MechsListRow";

7 7 8 -

import schema from "app/schema";

8 +

import {getEntitiesSession} from "features/entities/entitySelectors";

9 9 10 10

import {selectMech} from "../mechsActions";

11 11

import {selectCurrentMech} from "../mechSelectors";

12 12 13 13 14 14

const mapState = (state) => {

15 -

const session = schema.from(state.entities);

15 +

const session = getEntitiesSession(state);

16 16

const {Mech} = session;

17 17 18 18

const mechs = Mech.all().withModels.map(mechModel => mechModel.getId());

Original file line number Diff line number Diff line change

@@ -5,10 +5,10 @@ import {Table} from "semantic-ui-react";

5 5

import {getWeightClass} from "../mechSelectors";

6 6 7 7 8 -

import schema from "app/schema";

8 +

import {getEntitiesSession} from "features/entities/entitySelectors";

9 9 10 10

const mapState = (state, ownProps) => {

11 -

const session = schema.from(state.entities);

11 +

const session = getEntitiesSession(state);

12 12

const {Mech} = session;

13 13 14 14

let mech;

Original file line number Diff line number Diff line change

@@ -2,7 +2,7 @@ import React, {Component} from "react";

2 2

import {connect} from "react-redux";

3 3

import {Form, Dropdown, Grid, Button} from "semantic-ui-react";

4 4 5 -

import schema from "app/schema";

5 +

import {getEntitiesSession} from "features/entities/entitySelectors";

6 6 7 7

import FormEditWrapper from "common/components/FormEditWrapper";

8 8

@@ -49,7 +49,7 @@ const mapState = (state) => {

49 49 50 50

const currentPilot = selectCurrentPilot(state);

51 51 52 -

const session = schema.from(state.entities);

52 +

const session = getEntitiesSession(state);

53 53

const {Pilot} = session;

54 54 55 55

if(Pilot.hasId(currentPilot)) {

Original file line number Diff line number Diff line change

@@ -5,7 +5,7 @@ import {Table} from "semantic-ui-react";

5 5

import PilotsListHeader from "./PilotsListHeader";

6 6

import PilotsListRow from "./PilotsListRow";

7 7 8 -

import schema from "app/schema";

8 +

import {getEntitiesSession} from "features/entities/entitySelectors";

9 9 10 10

import {selectPilot} from "../pilotsActions";

11 11

import {selectCurrentPilot} from "../pilotsSelectors";

@@ -14,7 +14,7 @@ import {selectCurrentPilot} from "../pilotsSelectors";

14 14

const mapState = (state) => {

15 15

// Create a Redux-ORM Session from our "entities" slice, which

16 16

// contains the "tables" for each model type

17 -

const session = schema.from(state.entities);

17 +

const session = getEntitiesSession(state);

18 18 19 19

// Retrieve the model class that we need. Each Session

20 20

// specifically "binds" model classes to itself, so that

Original file line number Diff line number Diff line change

@@ -3,10 +3,10 @@ import {connect} from "react-redux";

3 3

import {Table} from "semantic-ui-react";

4 4

import _ from "lodash";

5 5 6 -

import schema from "app/schema";

6 +

import {getEntitiesSession} from "features/entities/entitySelectors";

7 7 8 8

const mapState = (state, ownProps) => {

9 -

const session = schema.from(state.entities);

9 +

const session = getEntitiesSession(state);

10 10

const {Pilot} = session;

11 11 12 12

let pilot;

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4