-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Pilot parsing, and load Pilots from sample data
- Loading branch information
1 parent
4ca88bd
commit 04a6785
Showing
3 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
import {createReducer} from "common/utils/reducerUtils"; | ||
|
||
import {DATA_LOADED} from "features/tools/toolConstants"; | ||
|
||
import schema from "app/schema" | ||
|
||
const initialState = schema.getDefaultState(); | ||
|
||
export function loadData(state, payload) { | ||
// Create a Redux-ORM session from our entities "tables" | ||
const session = schema.from(state); | ||
// Get a reference to the correct version of the Pilots class for this Session | ||
const {Pilot} = session; | ||
|
||
const {pilots} = payload; | ||
// Queue up creation commands for each pilot entry | ||
pilots.forEach(pilot => Pilot.parse(pilot)); | ||
|
||
// Apply the queued updates and return the updated "tables" | ||
return session.reduce(); | ||
} | ||
|
||
|
||
export default createReducer(initialState, { | ||
}); | ||
[DATA_LOADED] : loadData, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters