Comments (7)
Sounds like a good solution!
from redux.
Looks good for me too. I like the ideia of passing the store to get it's state. Passing a string to do that is something that I dislike in e.g. Flummox.
ES6 Map api is simple enough too.
π
from redux.
Maybe shouldn't even pass an ES6 Map and instead pass just the read
function. This reinforces that the state is meant to be read-only, doesn't introduce a dependency on a specific type and also forbids weird things like enumeration.
export function incrementIfOdd() {
return (dispatch, read) => {
if (read(counterStore) % 2 === 0) {
return;
}
dispatch(increment());
};
}
from redux.
π
from redux.
If somebody wants to PR this, I'll take it.
from redux.
If you do decide to PR this, note that internally we still need to use string keys for storage. This is because functions are hot-swapped on every file save, and their identities change. This is why we have an { key: string -> state: object }
object for state, and a { store: function -> key: string }
ES6 Map for mapping Store functions to state keys.
from redux.
Fixed via ac1be83, thanks!
from redux.
Related Issues (20)
- TS conflict between AppThunk and createAsyncThunk.withTypes HOT 2
- CodeSandbox is broken HOT 2
- Store state lost when page refresh HOT 1
- Using useSelector reload required to get updated value of state HOT 1
- providesTags does not work with callback when defining return type via TypeScript generic HOT 4
- [email protected]: Empty object check error HOT 4
- Math.random() usage HOT 3
- Instead of Why there should What HOT 1
- Missing link in Learning Resources -> Middleware
- updating redux from 5.0.0 to 5.0.1 Typescript errors HOT 18
- Could β plainβ class instances be stored in Redux store state. HOT 15
- Update copyright HOT 1
- Invalid external image link
- Small inconsistant in the docs: src/app/ or app/? HOT 2
- Redux core example app not working HOT 1
- Add combineSlices section to Code Splitting page
- doc not match in setup with nextjs HOT 1
- The wrong export in redux/examples/counter-ts/src/features/counter/counterSlice.ts HOT 1
- remove references to deprecated createStore
- Redux import type gone since upgrading to latest version with javascript (Next 14) HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux.