Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI #104

Merged
merged 2 commits into from
Oct 20, 2023
Merged

UI #104

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
406 changes: 278 additions & 128 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ export const experimentAsyncIterateIdThenReceiveInMethod = prepareActionCreator(

const experimentAsyncIterateIdThenReceiveInMethodCreator: MethodCreator = (concepts$?: UnifiedSubject) =>
createAsyncMethodWithConcepts((controller, action, concepts) => {
console.log('HIT');
setTimeout(() => {
const experimentState = selectState<ExperimentState>(concepts, experimentName);
if (action.strategy) {
const data = strategyData_unifyData<ExperimentState>(action.strategy, {id: experimentState.id});
const strategy = strategySuccess(action.strategy, data);
console.log('FIRE');
controller.fire(strategy);
}
controller.fire(action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type DebounceAsyncIterateIdThenReceiveInMethodPayload = {
setId: number;
}
export const experimentDebounceAsyncIterateIdThenReceiveInMethodType
= 'Experiment asynchronously iterate ID then receive in Method via Concept select';
= 'Debounce Experiment asynchronously iterate ID then receive in Method via Concept select';
export const experimentDebounceAsyncIterateIdThenReceiveInMethod
= prepareActionWithPayloadCreator<DebounceAsyncIterateIdThenReceiveInMethodPayload>(
experimentDebounceAsyncIterateIdThenReceiveInMethodType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy } from '../../../model/actionStrategy';
import { experimentAsyncIterateIdThenReceiveInMethod } from '../qualities/asyncIterateIdThenReceiveInMethod.quality copy';
import { experimentAsyncIterateIdThenReceiveInMethod } from '../qualities/asyncIterateIdThenReceiveInMethod.quality';

export const asyncIterateIdThenAddToDataTopic = 'Async iterate experiment ID then add to strategy data';
export function asyncIterateIdThenAddToData(): ActionStrategy {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy } from '../../../model/actionStrategy';
import { experimentDebounceAsyncIterateIdThenReceiveInMethod } from '../qualities/debounceAsyncIterateIdThenReceiveInMethod.quality copy 2';
import { experimentDebounceAsyncIterateIdThenReceiveInMethod } from '../qualities/debounceAsyncIterateIdThenReceiveInMethod.quality';

export const debounceAsyncIterateIdThenAddToDataTopic = 'Debounce async iterate experiment ID then add to strategy data';
export function debounceAsyncIterateIdThenAddToData(setId: number): ActionStrategy {
Expand Down
101 changes: 97 additions & 4 deletions src/test/debounceMethods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { axiumSelectLastStrategy, axiumSelectLastStrategyData } from '../concept
import { axiumKick } from '../concepts/axium/qualities/kick.quality';
import { Counter, counterName, createCounterConcept } from '../concepts/counter/counter.concept';
import { ExperimentState, createExperimentConcept, createExperimentState, experimentName } from '../concepts/experiment/experiment.concept';
import { experimentDebounceAsyncIterateIdThenReceiveInMethodQuality } from '../concepts/experiment/qualities/debounceAsyncIterateIdThenReceiveInMethod.quality copy 2';
import { experimentDebounceAsyncIterateIdThenReceiveInMethodQuality } from '../concepts/experiment/qualities/debounceAsyncIterateIdThenReceiveInMethod.quality';
import { asyncDebounceNextActionNodeQuality } from '../concepts/experiment/qualities/debounceAsyncNextActionNode.quality';
import { DebounceIterateIdThenReceiveInMethodPayload, experimentDebounceIterateIdThenReceiveInMethodQuality } from '../concepts/experiment/qualities/debounceIterateIdThenReceiveInMethod.quality';
import { debounceNextActionNodeQuality } from '../concepts/experiment/qualities/debounceNextActionNode.quality';
import { experimentAsyncDebounceAddOneStrategy } from '../concepts/experiment/strategies/asyncDebounceAddOne.strategy';
import { experimentDebounceAddOneStrategy } from '../concepts/experiment/strategies/debounceAddOne.strategy';
import { debounceAsyncIterateIdThenAddToData, debounceAsyncIterateIdThenAddToDataTopic } from '../concepts/experiment/strategies/debounceAsyncIterateIdThenAddToData.strategy';
import { debounceIterateIdThenAddToData, debounceIterateIdThenAddToDataTopic } from '../concepts/experiment/strategies/debounceIterateIdThenAddToData.strategy copy';
import { debounceIterateIdThenAddToData, debounceIterateIdThenAddToDataTopic } from '../concepts/experiment/strategies/debounceIterateIdThenAddToData.strategy';
import { strategyBegin } from '../model/actionStrategy';
import { createAxium } from '../model/axium';
import { selectSlice, selectState } from '../model/selector';
Expand Down Expand Up @@ -151,11 +151,58 @@ test('Debounce Method Test with Concepts id comparison', (done) => {
expect(data.setId).toBe(2);
expect(experimentState.id).toBe(3);
plan.conclude();
done();
}
}
}
]);
setTimeout(() => {
console.log('BEGIN 2ND PLAN');
const secondPlan = axium.stage('Second experiment debounce add one', [
(concepts, dispatch) => {
console.log('2 Debounce initial dispatch');
const experimentState = selectState<ExperimentState>(concepts, experimentName);
dispatch(strategyBegin(debounceIterateIdThenAddToData(experimentState.id)), {
iterateStage: true
});
},
(concepts, dispatch) => {
const experimentState = selectState<ExperimentState>(concepts, experimentName);
const lastStrategy = selectSlice(concepts, axiumSelectLastStrategy);
const data = selectSlice<ExperimentState>(concepts, axiumSelectLastStrategyData);
console.log('2 Debounce: ', experimentState.id, lastStrategy, data);
dispatch(strategyBegin(debounceIterateIdThenAddToData(experimentState.id)), {
iterateStage: true
});
},
(concepts, dispatch) => {
const experimentState = selectState<ExperimentState>(concepts, experimentName);
const lastStrategy = selectSlice(concepts, axiumSelectLastStrategy);
const data = selectSlice<ExperimentState>(concepts, axiumSelectLastStrategyData);
console.log('2 Debounce: ', experimentState.id, lastStrategy, data);
dispatch(strategyBegin(debounceIterateIdThenAddToData(experimentState.id)), {
iterateStage: true
});
},
(concepts, _) => {
const lastStrategy = selectSlice(concepts, axiumSelectLastStrategy);
const experimentState = selectState<ExperimentState>(concepts, experimentName);
const data = selectSlice<ExperimentState & DebounceIterateIdThenReceiveInMethodPayload>(concepts, axiumSelectLastStrategyData);
console.log('2 Debounce: ', experimentState.id, lastStrategy, data);
if (lastStrategy === debounceIterateIdThenAddToDataTopic) {
if (data && data.id === 6) {
console.log('2 Strategy Data: ', data, 'Experiment State ID: ', experimentState.id);
expect(data.id).toBe(6);
expect(data.setId).toBe(5);
expect(experimentState.id).toBe(6);
secondPlan.conclude();
done();
}
}
}
]);
// Kick
axium.dispatch(axiumKick());
}, 1000);
});

test('Debounce Async Method Test with Concepts id comparison', (done) => {
Expand Down Expand Up @@ -198,9 +245,55 @@ test('Debounce Async Method Test with Concepts id comparison', (done) => {
expect(data.setId).toBe(2);
expect(experimentState.id).toBe(3);
plan.conclude();
done();
}
}
}
]);
setTimeout(() => {
console.log('BEGIN 2ND PLAN');
const secondPlan = axium.stage('Second experiment async debounce add one', [
(concepts, dispatch) => {
const experimentState = selectState<ExperimentState>(concepts, experimentName);
dispatch(strategyBegin(debounceAsyncIterateIdThenAddToData(experimentState.id)), {
iterateStage: true
});
},
(concepts, dispatch) => {
const experimentState = selectState<ExperimentState>(concepts, experimentName);
const lastStrategy = selectSlice(concepts, axiumSelectLastStrategy);
const data = selectSlice<ExperimentState>(concepts, axiumSelectLastStrategyData);
console.log('2 Async Debounce: ', experimentState.id, lastStrategy, data);
dispatch(strategyBegin(debounceAsyncIterateIdThenAddToData(experimentState.id)), {
iterateStage: true
});
},
(concepts, dispatch) => {
const experimentState = selectState<ExperimentState>(concepts, experimentName);
const lastStrategy = selectSlice(concepts, axiumSelectLastStrategy);
const data = selectSlice<ExperimentState>(concepts, axiumSelectLastStrategyData);
console.log('2 Async Debounce: ', experimentState.id, lastStrategy, data);
dispatch(strategyBegin(debounceAsyncIterateIdThenAddToData(experimentState.id)), {
iterateStage: true
});
},
(concepts, _) => {
const lastStrategy = selectSlice(concepts, axiumSelectLastStrategy);
const experimentState = selectState<ExperimentState>(concepts, experimentName);
const data = selectSlice<ExperimentState & DebounceIterateIdThenReceiveInMethodPayload>(concepts, axiumSelectLastStrategyData);
console.log('2 Async Debounce: ', experimentState.id, lastStrategy, data);
if (lastStrategy === debounceAsyncIterateIdThenAddToDataTopic) {
if (data && data.id === 6) {
console.log('Strategy Data: ', data, 'Experiment State ID: ', experimentState.id);
expect(data.id).toBe(6);
expect(data.setId).toBe(5);
expect(experimentState.id).toBe(6);
secondPlan.conclude();
done();
}
}
}
]);
// Kick
axium.dispatch(axiumKick());
}, 1000);
});
3 changes: 1 addition & 2 deletions src/test/methodHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { axiumSelectLastStrategy, axiumSelectLastStrategyData } from '../concept
import { ExperimentState, createExperimentConcept, createExperimentState, experimentName } from '../concepts/experiment/experiment.concept';
import {
experimentAsyncIterateIdThenReceiveInMethodQuality
} from '../concepts/experiment/qualities/asyncIterateIdThenReceiveInMethod.quality copy';
} from '../concepts/experiment/qualities/asyncIterateIdThenReceiveInMethod.quality';
import { experimentIterateIdThenReceiveInMethodQuality } from '../concepts/experiment/qualities/iterateIdThenReceiveInMethod.quality';
import { mockToTrueQuality } from '../concepts/experiment/qualities/mockTrue.quality';
import { timerEmitActionQuality } from '../concepts/experiment/qualities/timerEmitAction.quality';
Expand Down Expand Up @@ -104,7 +104,6 @@ test('Async Method Test with Concepts id comparison', (done) => {
(concepts, _) => {
const lastStrategy = selectSlice(concepts, axiumSelectLastStrategy);
const experimentState = selectState<ExperimentState>(concepts, experimentName);
console.log('PING', experimentState);
if (lastStrategy === asyncIterateIdThenAddToDataTopic) {
const data = selectSlice<ExperimentState>(concepts, axiumSelectLastStrategyData);
if (data) {
Expand Down