Skip to content

[Feature] Add tests of state manager #2023

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
move Store type to Store.ts
  • Loading branch information
ilyamore88 committed Apr 10, 2022
commit 01f8f92fa7ea598f5e639d9e844ea33220ba9645
9 changes: 1 addition & 8 deletions src/components/store/createStore.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { EditorState } from './types/EditorState';
import { Reducer } from './types/Reducer';
import { Action } from './types/Action';

interface Store {
subscribe: (listener: () => void) => (() => void);

dispatch: (action: Action) => void;

getState: () => EditorState;
}
import { Store } from './types/Store';

/**
* Function creates store and returns functions for use it
Expand Down
28 changes: 28 additions & 0 deletions src/components/store/types/Store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Action } from './Action';
import { EditorState } from './EditorState';

/**
* Store type contains functions for use it
*/
export type Store = {
/**
* Function for subscribing on state changes
*
* @param listener - function, that will execute every state change
*
* @returns {() => void} unsubscribe function
*/
subscribe: (listener: () => void) => (() => void);

/**
* Dispatch action on the current state
*
* @param action - action that will be dispatched
*/
dispatch: (action: Action) => void;

/**
* Function returns current state
*/
getState: () => EditorState;
}