You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constants.ts - Constant values for the module. This currently has action types and route paths.
actions.ts - These are the simple action creators. Everything here is synchronous, "plain" redux. Eg. a function that takes some props and directly returns an action object. This also exports all of the action types for reducers.
model.ts - This contains the interface for the modules local state. For more complicated modules in the future it may contain selectors for selecting, or manipulating parts of this state.
reducer.ts - This contains the reducer function that handles the actions and returns the updated state tree.
thunks.ts - These are async actions. See redux-thunk. Basically the function here can make async events and dispatch other actions or other thunks. This is where side affects like network requests, IO, or updating navigation programatically should take place.
index.ts - This is the barrel file. It re-exports the relevant bits for external consumption. No files outside of this state directory should import any of them directly. Instead they should be imported from the barrel. Eg. import {constants} from "modules/editor/state" instead of import * as constants from "modules/editor/state/constants".
Changes
I'm looking to streamline this by doing the following:
Add 2 new base classes. ReduxReducer and ReduxActions. Each new state structure will extend these.
ReduxActions will contain most of @library/state/utility as protected methods for it's subclasses to use.
Re-arranging
The previous file contents will be moved as follows:
constants.ts - Static constants on the Actions class.
actions.ts - Private static methods on the Actions class.
model.ts - Public static methods on the Reducer class.
reducer.ts - Public instance methods on the Reducer class.
thunks.ts - Public instance methods on the Actions class.
index.ts - Removed. No longer necessary.
Old utility methods
The old utility methods will be marked as deprecated and moved shortly after the initial implementation. The current call sites here that will need to be updated are the rich-editor's couple reducers, which already needed an update, and the authenticate page's reducer.
The text was updated successfully, but these errors were encountered:
While bringup @initvector up on frontends project structure it became apparent that things were spread over too many files. This new structure was introduced in https://github.com/vanilla/knowledge/pull/163#structure.
Overview
This is what the state structure looks like now:
modules/editor/state
constants.ts
- Constant values for the module. This currently has action types and route paths.actions.ts
- These are the simple action creators. Everything here is synchronous, "plain" redux. Eg. a function that takes some props and directly returns an action object. This also exports all of the action types for reducers.model.ts
- This contains the interface for the modules local state. For more complicated modules in the future it may contain selectors for selecting, or manipulating parts of this state.reducer.ts
- This contains the reducer function that handles the actions and returns the updated state tree.thunks.ts
- These are async actions. See redux-thunk. Basically the function here can make async events and dispatch other actions or other thunks. This is where side affects like network requests, IO, or updating navigation programatically should take place.index.ts
- This is the barrel file. It re-exports the relevant bits for external consumption. No files outside of this state directory should import any of them directly. Instead they should be imported from the barrel. Eg.import {constants} from "modules/editor/state"
instead ofimport * as constants from "modules/editor/state/constants"
.Changes
I'm looking to streamline this by doing the following:
ReduxReducer
andReduxActions
. Each new state structure will extend these.ReduxActions
will contain most of@library/state/utility
asprotected
methods for it's subclasses to use.Re-arranging
The previous file contents will be moved as follows:
constants.ts
- Static constants on theActions
class.actions.ts
- Private static methods on theActions
class.model.ts
- Public static methods on theReducer
class.reducer.ts
- Public instance methods on theReducer
class.thunks.ts
- Public instance methods on theActions
class.index.ts
- Removed. No longer necessary.Old utility methods
The old utility methods will be marked as deprecated and moved shortly after the initial implementation. The current call sites here that will need to be updated are the
rich-editor
's couple reducers, which already needed an update, and the authenticate page's reducer.The text was updated successfully, but these errors were encountered: