Wire in redux-observables and add basic epic

This commit is contained in:
James Greenaway
2019-01-30 16:01:37 +00:00
parent d03859c220
commit 94423c408a
10 changed files with 87 additions and 21 deletions

View File

@@ -0,0 +1,25 @@
import { combineEpics, Epic, ofType } from 'redux-observable';
import { map, tap, ignoreElements } from 'rxjs/operators';
import { Action } from '../actions';
import { State } from '../reducers';
type AppEpic = Epic<Action, Action, State>;
const logWorkloadSubmissions: AppEpic = (action$, state$) => (
action$.pipe(
ofType('WORKLOAD_SUBMIT'),
map(action => action.payload),
tap((payload) => console.log('Workload submitted', payload)),
ignoreElements(),
)
);
export const epics = combineEpics(
logWorkloadSubmissions,
);
export default epics;

View File

@@ -1,3 +1,4 @@
export * from './actions';
export * from './reducers';
export * from './epics';
export * from './services';

View File

@@ -1,20 +1,20 @@
import { Action } from './actions';
import { Status } from './types';
interface Entry<id extends number> {
id: id;
interface Entry<Id extends number> {
id: Id;
completeDate: Date;
status: Status;
}
export type Store = {
[id in number]: Entry<id>;
export type State = {
[Id in number]: Entry<Id>;
};
const initialState: Store = {};
const initialState: State = {};
export const reducer = (state: Store = initialState, action: Action): Store => {
export const reducer = (state: State = initialState, action: Action): State => {
switch (action.type) {
case 'WORKLOAD_CREATED':
return {