Skip to content

Commit

Permalink
Light documentation of helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
REllEK-IO committed Oct 19, 2023
1 parent 338a1e4 commit 1ff3fe4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions ActionStrategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,35 @@ The same is true when accessing the payload from a reducer, method, or principle
SomethingFactory<AnotherFactor<Factory>>
```
This was a purposeful design choice, if you find yourself doing such. Known this system is already complicated enough.

## Helper Functions for Standard Method Creators
*Note you still need to create a function of MethodCreator to use these Helpers*
```typescript
export const createMethod =
(method: (action: Action) => Action): [Method, Subject<Action>] => {}
export const createMethodWithConcepts =
(method: (action: Action) => Action, concepts$: UnifiedSubject): [Method, Subject<Action>] => {}
export const createAsyncMethod =
(asyncMethod: (controller: ActionController, action: Action) => void): [Method, Subject<Action>] => {}
export const createAsyncMethodWithConcepts =
(asyncMethodWithConcepts: (controller: ActionController, action: Action, concepts: Concept[]) => void, concepts$: UnifiedSubject)
: [Method, Subject<Action>] => {}
export const createMethodDebounce =
(method: (action: Action) => Action, duration: number): [Method, Subject<Action>] => {}
export const createMethodDebounceWithConcepts =
(methodWithConcepts: (action: Action, concepts: Concept[]) => Action, concepts$: UnifiedSubject, duration: number)
: [Method, Subject<Action>] => {}
export const createAsyncMethodDebounce =
(asyncMethod: (controller: ActionController, action: Action) => void, duration: number): [Method, Subject<Action>] => {}
export const createAsyncMethodDebounceWithConcepts =
(asyncMethodWithConcepts: (controller: ActionController, action: Action, concepts: Concept[]) =>
void, concepts$: UnifiedSubject, duration: number): [Method, Subject<Action>] => {}
```
* createMethod - Your standard method, be sure to handle the action.strategy via one of the strategy decision functions, in addition to passing the action if there is no attached strategy.
* createMethodWithConcepts - This will allow your method to have the most recent concepts to be accessed via the asyncMethod function.
* createAsyncMethod - Handled differently than the rest, you will have to use the passed controller to fire your actions back into the action stream.
* createAsyncMethodWithConcepts - Will also have access to the most recent concepts.
* createMethodDebounce - After the first action, this will filter actions within the duration to be set to the conclude action.
* createMethodDebounceWithConcepts - Will filter actions within the duration while providing access to the most recent concepts.
* createAsyncMethodDebounce - Will not disengage the initial ActionController, but will allow debounced actions to pass through when filtered as conclude actions. And will fire the first action upon its own conditions are met asynchronously.
* createAsyncMethodDebounceWithConcepts - Filters and then first the first action once conditions are met, and provides access to the most recent concepts.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@phuire/strx",
"version": "0.0.37",
"version": "0.0.38",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down

0 comments on commit 1ff3fe4

Please sign in to comment.