-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constistency, debounce fires most recent action after duration.
- Loading branch information
Showing
16 changed files
with
437 additions
and
26 deletions.
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
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
42 changes: 42 additions & 0 deletions
42
src/concepts/experiment/qualities/asyncIterateIdThenReceiveInMethod.quality copy.ts
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { MethodCreator, defaultMethodCreator, defaultReducer } from '../../../model/concept'; | ||
import { Action, prepareActionCreator } from '../../../model/action'; | ||
import { createQuality } from '../../../model/concept'; | ||
import { ExperimentState, experimentName } from '../experiment.concept'; | ||
import { UnifiedSubject } from '../../../model/stagePlanner'; | ||
import { createAsyncMethodWithConcepts, createMethodWithConcepts } from '../../../model/method'; | ||
import { selectState } from '../../../model/selector'; | ||
import { strategySuccess } from '../../../model/actionStrategy'; | ||
import { strategyData_unifyData } from '../../../model/actionStrategyData'; | ||
|
||
export const experimentAsyncIterateIdThenReceiveInMethodType | ||
= 'Experiment asynchronously iterate ID then receive in Method via Concept select'; | ||
|
||
export const experimentAsyncIterateIdThenReceiveInMethod = prepareActionCreator(experimentAsyncIterateIdThenReceiveInMethodType); | ||
|
||
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); | ||
}, 50); | ||
}, concepts$ as UnifiedSubject); | ||
|
||
function experimentAsyncIterateIdThenReceiveInMethodReducer(state: ExperimentState, _: Action): ExperimentState { | ||
return { | ||
...state, | ||
id: state.id + 1 | ||
}; | ||
} | ||
|
||
export const experimentAsyncIterateIdThenReceiveInMethodQuality = createQuality( | ||
experimentAsyncIterateIdThenReceiveInMethodType, | ||
experimentAsyncIterateIdThenReceiveInMethodReducer, | ||
experimentAsyncIterateIdThenReceiveInMethodCreator | ||
); |
52 changes: 52 additions & 0 deletions
52
...concepts/experiment/qualities/debounceAsyncIterateIdThenReceiveInMethod.quality copy 2.ts
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { MethodCreator } from '../../../model/concept'; | ||
import { Action, prepareActionWithPayloadCreator } from '../../../model/action'; | ||
import { createQuality } from '../../../model/concept'; | ||
import { ExperimentState, experimentName } from '../experiment.concept'; | ||
import { UnifiedSubject } from '../../../model/stagePlanner'; | ||
import { createAsyncMethodDebounceWithConcepts } from '../../../model/method'; | ||
import { selectPayload, selectState } from '../../../model/selector'; | ||
import { strategySuccess } from '../../../model/actionStrategy'; | ||
import { strategyData_unifyData } from '../../../model/actionStrategyData'; | ||
|
||
export type DebounceAsyncIterateIdThenReceiveInMethodPayload = { | ||
setId: number; | ||
} | ||
export const experimentDebounceAsyncIterateIdThenReceiveInMethodType | ||
= 'Experiment asynchronously iterate ID then receive in Method via Concept select'; | ||
export const experimentDebounceAsyncIterateIdThenReceiveInMethod | ||
= prepareActionWithPayloadCreator<DebounceAsyncIterateIdThenReceiveInMethodPayload>( | ||
experimentDebounceAsyncIterateIdThenReceiveInMethodType | ||
); | ||
|
||
const experimentDebounceAsyncIterateIdThenReceiveInMethodCreator: MethodCreator = (concepts$?: UnifiedSubject) => | ||
createAsyncMethodDebounceWithConcepts((controller, action, concepts) => { | ||
setTimeout(() => { | ||
const payload = selectPayload<DebounceAsyncIterateIdThenReceiveInMethodPayload>(action); | ||
const experimentState = selectState<ExperimentState>(concepts, experimentName); | ||
if (action.strategy) { | ||
const data = strategyData_unifyData<ExperimentState & DebounceAsyncIterateIdThenReceiveInMethodPayload>( | ||
action.strategy, | ||
{ | ||
id: experimentState.id, | ||
setId: payload.setId | ||
} | ||
); | ||
const strategy = strategySuccess(action.strategy, data); | ||
controller.fire(strategy); | ||
} | ||
controller.fire(action); | ||
}, 50); | ||
}, concepts$ as UnifiedSubject, 500); | ||
|
||
function experimentDebounceAsyncIterateIdThenReceiveInMethodReducer(state: ExperimentState, _: Action): ExperimentState { | ||
return { | ||
...state, | ||
id: state.id + 1 | ||
}; | ||
} | ||
|
||
export const experimentDebounceAsyncIterateIdThenReceiveInMethodQuality = createQuality( | ||
experimentDebounceAsyncIterateIdThenReceiveInMethodType, | ||
experimentDebounceAsyncIterateIdThenReceiveInMethodReducer, | ||
experimentDebounceAsyncIterateIdThenReceiveInMethodCreator | ||
); |
46 changes: 46 additions & 0 deletions
46
src/concepts/experiment/qualities/debounceIterateIdThenReceiveInMethod.quality.ts
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { MethodCreator, defaultMethodCreator, defaultReducer } from '../../../model/concept'; | ||
import { Action, prepareActionCreator, prepareActionWithPayloadCreator } from '../../../model/action'; | ||
import { createQuality } from '../../../model/concept'; | ||
import { ExperimentState, experimentName } from '../experiment.concept'; | ||
import { UnifiedSubject } from '../../../model/stagePlanner'; | ||
import { createMethodDebounceWithConcepts, createMethodWithConcepts } from '../../../model/method'; | ||
import { selectPayload, selectState } from '../../../model/selector'; | ||
import { strategySuccess } from '../../../model/actionStrategy'; | ||
import { strategyData_unifyData } from '../../../model/actionStrategyData'; | ||
|
||
export type DebounceIterateIdThenReceiveInMethodPayload = { | ||
setId: number; | ||
} | ||
export const experimentDebounceIterateIdThenReceiveInMethodType = | ||
'Experiment debounce iterate ID then receive in Method via Concept select'; | ||
|
||
export const experimentDebounceIterateIdThenReceiveInMethod = | ||
prepareActionWithPayloadCreator<DebounceIterateIdThenReceiveInMethodPayload>(experimentDebounceIterateIdThenReceiveInMethodType); | ||
|
||
const experimentDebounceIterateIdThenReceiveInMethodCreator: MethodCreator = (concepts$?: UnifiedSubject) => | ||
createMethodDebounceWithConcepts((action, concepts) => { | ||
const payload = selectPayload<DebounceIterateIdThenReceiveInMethodPayload>(action); | ||
const experimentState = selectState<ExperimentState>(concepts, experimentName); | ||
if (action.strategy) { | ||
const data = strategyData_unifyData<ExperimentState & DebounceIterateIdThenReceiveInMethodPayload>(action.strategy, { | ||
id: experimentState.id, | ||
setId: payload.setId | ||
}); | ||
const strategy = strategySuccess(action.strategy, data); | ||
return strategy; | ||
} | ||
return action; | ||
}, concepts$ as UnifiedSubject, 500); | ||
|
||
function experimentDebounceIterateIdThenReceiveInMethodReducer(state: ExperimentState, _: Action): ExperimentState { | ||
return { | ||
...state, | ||
id: state.id + 1 | ||
}; | ||
} | ||
|
||
export const experimentDebounceIterateIdThenReceiveInMethodQuality = createQuality( | ||
experimentDebounceIterateIdThenReceiveInMethodType, | ||
experimentDebounceIterateIdThenReceiveInMethodReducer, | ||
experimentDebounceIterateIdThenReceiveInMethodCreator | ||
); |
37 changes: 37 additions & 0 deletions
37
src/concepts/experiment/qualities/iterateIdThenReceiveInMethod.quality.ts
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MethodCreator, defaultMethodCreator, defaultReducer } from '../../../model/concept'; | ||
import { Action, prepareActionCreator } from '../../../model/action'; | ||
import { createQuality } from '../../../model/concept'; | ||
import { ExperimentState, experimentName } from '../experiment.concept'; | ||
import { UnifiedSubject } from '../../../model/stagePlanner'; | ||
import { createMethodWithConcepts } from '../../../model/method'; | ||
import { selectState } from '../../../model/selector'; | ||
import { strategySuccess } from '../../../model/actionStrategy'; | ||
import { strategyData_unifyData } from '../../../model/actionStrategyData'; | ||
|
||
export const experimentIterateIdThenReceiveInMethodType = 'Experiment iterate ID then receive in Method via Concept select'; | ||
|
||
export const experimentIterateIdThenReceiveInMethod = prepareActionCreator(experimentIterateIdThenReceiveInMethodType); | ||
|
||
const experimentIterateIdThenReceiveInMethodCreator: MethodCreator = (concepts$?: UnifiedSubject) => | ||
createMethodWithConcepts((action, concepts) => { | ||
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); | ||
return strategy; | ||
} | ||
return action; | ||
}, concepts$ as UnifiedSubject); | ||
|
||
function experimentIterateIdThenReceiveInMethodReducer(state: ExperimentState, _: Action): ExperimentState { | ||
return { | ||
...state, | ||
id: state.id + 1 | ||
}; | ||
} | ||
|
||
export const experimentIterateIdThenReceiveInMethodQuality = createQuality( | ||
experimentIterateIdThenReceiveInMethodType, | ||
experimentIterateIdThenReceiveInMethodReducer, | ||
experimentIterateIdThenReceiveInMethodCreator | ||
); |
17 changes: 17 additions & 0 deletions
17
src/concepts/experiment/strategies/asyncIterateIdThenAddToData.strategy.ts
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy } from '../../../model/actionStrategy'; | ||
import { experimentAsyncIterateIdThenReceiveInMethod } from '../qualities/asyncIterateIdThenReceiveInMethod.quality copy'; | ||
|
||
export const asyncIterateIdThenAddToDataTopic = 'Async iterate experiment ID then add to strategy data'; | ||
export function asyncIterateIdThenAddToData(): ActionStrategy { | ||
const stepOne = createActionNode(experimentAsyncIterateIdThenReceiveInMethod(), { | ||
successNode: null, | ||
failureNode: null, | ||
}); | ||
|
||
const params: ActionStrategyParameters = { | ||
topic: asyncIterateIdThenAddToDataTopic, | ||
initialNode: stepOne, | ||
}; | ||
|
||
return createStrategy(params); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/concepts/experiment/strategies/debounceAsyncIterateIdThenAddToData.strategy.ts
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy } from '../../../model/actionStrategy'; | ||
import { experimentDebounceAsyncIterateIdThenReceiveInMethod } from '../qualities/debounceAsyncIterateIdThenReceiveInMethod.quality copy 2'; | ||
|
||
export const debounceAsyncIterateIdThenAddToDataTopic = 'Debounce async iterate experiment ID then add to strategy data'; | ||
export function debounceAsyncIterateIdThenAddToData(setId: number): ActionStrategy { | ||
const stepOne = createActionNode(experimentDebounceAsyncIterateIdThenReceiveInMethod({setId}), { | ||
successNode: null, | ||
failureNode: null, | ||
}); | ||
|
||
const params: ActionStrategyParameters = { | ||
topic: debounceAsyncIterateIdThenAddToDataTopic, | ||
initialNode: stepOne, | ||
}; | ||
|
||
return createStrategy(params); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/concepts/experiment/strategies/debounceIterateIdThenAddToData.strategy copy.ts
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy } from '../../../model/actionStrategy'; | ||
import { experimentDebounceIterateIdThenReceiveInMethod } from '../qualities/debounceIterateIdThenReceiveInMethod.quality'; | ||
|
||
export const debounceIterateIdThenAddToDataTopic = 'Debounce iterate experiment ID then add to strategy data'; | ||
export function debounceIterateIdThenAddToData(setId: number): ActionStrategy { | ||
const stepOne = createActionNode(experimentDebounceIterateIdThenReceiveInMethod({setId}), { | ||
successNode: null, | ||
failureNode: null, | ||
}); | ||
|
||
const params: ActionStrategyParameters = { | ||
topic: debounceIterateIdThenAddToDataTopic, | ||
initialNode: stepOne, | ||
}; | ||
|
||
return createStrategy(params); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/concepts/experiment/strategies/iterateIdThenAddToData.strategy.ts
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ActionStrategy, ActionStrategyParameters, createActionNode, createStrategy } from '../../../model/actionStrategy'; | ||
import { experimentIterateIdThenReceiveInMethod } from '../qualities/iterateIdThenReceiveInMethod.quality'; | ||
|
||
export const iterateIdThenAddToDataTopic = 'Iterate experiment ID then add to strategy data'; | ||
export function iterateIdThenAddToData(): ActionStrategy { | ||
const stepOne = createActionNode(experimentIterateIdThenReceiveInMethod(), { | ||
successNode: null, | ||
failureNode: null, | ||
}); | ||
|
||
const params: ActionStrategyParameters = { | ||
topic: iterateIdThenAddToDataTopic, | ||
initialNode: stepOne, | ||
}; | ||
|
||
return createStrategy(params); | ||
} |
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
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
Oops, something went wrong.