couzic / lenrix Goto Github PK
View Code? Open in Web Editor NEWType-safe, reactive, focusable redux store wrapper
License: MIT License
Type-safe, reactive, focusable redux store wrapper
License: MIT License
store.changeDetectionStategies({
myValue: (previousValue, nextValue) => previousValue.myField === nextValue.myField
})
Since this case is so common:
store.changeDetectionSelectors({
birthDate: _ => _.getTime()
})
Add the ability to do something like:
store.updateFieldValues(state => ({
prop1: state.prop2,
prop2: state.prop1
}))
Requires lenrix #4 to be solved first
// Registering update with unknown action @shouldNotButDoesCompile
store.updates(_ => ({
doString: s => _.focusPath('counter').setValue(42),
unknown: s => _.focusPath('counter').setValue(42),
}))
When testing, logging should be completely disabled.
Define and implement the API to allow the dispatch and handling of actions on a Store. Open questions:
Syntactic sugar for computeFromField(['singleField'], singleField => ...)
Syntactic sugar for Store.recompose()
Hide store reference behind proxy LightStore instance
In order to make webpack hot module reload work properly we need to have something like this to update the store when an update, a computed value or an epic is modified.
redux and redux-observable already implement this feature.
Do you think it is possible ? easy ?
if (module.hot) {
module.hot.accept('../reducers', () =>
store.replaceReducer(require('../reducers')) // eslint-disable-line global-require
);
const epic$ = new BehaviorSubject(rootEpic);
module.hot.accept('./where-ever-they-are', () => {
const nextRootEpic = require('./where-ever-they-are').rootEpic;
epic$.next(nextRootEpic);
});
}
https://redux-observable.js.org/docs/recipes/HotModuleReplacement.html
store
.computeFromFields(
['selectedStatsProduct'],
({ selectedStatsProduct }) => ({
selectedStatsProduct,
}),
)
.focusPath(
[...],
['selectedStatsProduct'],
)
should be:
store
.focusPath(
[...],
['selectedStatsProduct'],
)
Useful to set state or slice of state back to initial state
Logger should be configured at the store level, enabling logging from only single store to reduce console noise.
Think of and implement a better API
.computeFrom(
_ => ({
selectedCategoryProduct: _.focusPath(
'productSelect',
'selectedCategoryProduct',
),
}),
({ selectedCategoryProduct }) => ({
statsProductOptions:
selectedCategoryProduct === undefined
? undefined
: selectedCategoryProduct.products.map(toOption),
}),
)
Problem: statsProductOptions never get undefined
One class might be enough
currentState
should hold all readonly fields
Example:
const extract$: Observable<{a: A, c: C}> = store.extract({
a: store.lens.focusOn('a'),
c: store.lens.focusOn('b').focusOn('c')
})
extract$
only emits for new values of a
or c
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.