Delete demo code and add service demo to epics file
This commit is contained in:
@@ -21,72 +21,6 @@ epicMiddleware.run(epics);
|
||||
// demo actions
|
||||
store.dispatch(WorkloadActions.submit({ complexity: 10 }));
|
||||
store.dispatch(WorkloadActions.created({ id: 0, complexity: 10, completeDate: moment().add(10, 'second').toDate() }));
|
||||
store.dispatch(WorkloadActions.created({ id: 1, complexity: 10, completeDate: moment().add(18, 'second').toDate() }));
|
||||
|
||||
|
||||
/*
|
||||
|
||||
import * as WorkloadActions from './state/workloads/actions';
|
||||
import { WorkloadService } from './state/workloads/services';
|
||||
|
||||
// demo store
|
||||
|
||||
store.subscribe(() => {
|
||||
console.log('store workload[0]', store.getState().workloads[0]);
|
||||
});
|
||||
|
||||
store.dispatch(WorkloadActions.submit({ complexity: 100 }));
|
||||
store.dispatch(WorkloadActions.created({ id: 0, complexity: 100, completeDate: new Date() }));
|
||||
store.dispatch(WorkloadActions.cancel({ id: 0 }));
|
||||
store.dispatch(WorkloadActions.updateStatus({ id: 0, status: 'SUCCESS' }));
|
||||
|
||||
|
||||
// demo workloadService
|
||||
|
||||
const workloadService = new WorkloadService();
|
||||
|
||||
workloadService.create({ complexity: 1 })
|
||||
.then(console.log.bind(console, 'create 0'));
|
||||
workloadService.cancel({ id: 0 })
|
||||
.then(console.log.bind(console, 'cancel 0'));
|
||||
setTimeout(() => workloadService.checkStatus({ id: 0 })
|
||||
.then(console.log.bind(console, 'checkStatus 0')), 100);
|
||||
|
||||
workloadService.create({ complexity: 2 })
|
||||
.then(console.log.bind(console, 'create 1'));
|
||||
workloadService.checkStatus({ id: 1 })
|
||||
.then(console.log.bind(console, 'checkStatus 1'));
|
||||
setTimeout(() => workloadService.checkStatus({ id: 1 })
|
||||
.then(console.log.bind(console, 'checkStatus 1')), 200);
|
||||
|
||||
workloadService.create({ complexity: 2 })
|
||||
.then(console.log.bind(console, 'create 2'));
|
||||
workloadService.checkStatus({ id: 2 })
|
||||
.then(console.log.bind(console, 'checkStatus 2'));
|
||||
setTimeout(() => workloadService.checkStatus({ id: 2 })
|
||||
.then(console.log.bind(console, 'checkStatus 2')), 200);
|
||||
|
||||
|
||||
// pretend epic code
|
||||
|
||||
function createWorkload(action$) {
|
||||
action$
|
||||
.pipe(
|
||||
ofType('WORKLOAD_SUBMIT'),
|
||||
tap((action) => {
|
||||
console.log(`workload has been submitted with complexity of ${action.payload.complexity}`)
|
||||
}),
|
||||
switchMap((action) => (
|
||||
fromPromise(workloadService.create({ complexity: action.payload.complexity }))
|
||||
)),
|
||||
map((response) => (
|
||||
WorkloadActions.created(response))
|
||||
))
|
||||
);
|
||||
|
||||
return empty();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
ReactDOM.render(
|
||||
|
||||
@@ -8,6 +8,12 @@ import { State } from '../reducer';
|
||||
type AppEpic = Epic<Action, Action, State>;
|
||||
|
||||
|
||||
// import { WorkloadService } from './services';
|
||||
// const workloadService = new WorkloadService();
|
||||
// workloadService.create({ complexity: 1 })
|
||||
// .then(console.log.bind(console, 'workloadService create'));
|
||||
|
||||
|
||||
const logWorkloadSubmissions: AppEpic = (action$, state$) => (
|
||||
action$.pipe(
|
||||
ofType('WORKLOAD_SUBMIT'),
|
||||
|
||||
Reference in New Issue
Block a user