choko-org / redux-boot Goto Github PK
View Code? Open in Web Editor NEWModular Redux bootstrap with asynchronous side-effects.
License: MIT License
Modular Redux bootstrap with asynchronous side-effects.
License: MIT License
For example to use https://github.com/zalmoxisus/redux-devtools-extension
We opted for GPL 3 because we understand that:
Conversation in pt_BR (sorry) between @recidive and @sebas5384 (me):
henrique [8:37 PM]
okk dei uma lida lá[8:37]
eu só tenho um problema qto a GPL 3, que é a de restringir o uso, só isso[8:37]
uns podem optar por não usá-lo apenas por conta dissosebas5384 [8:38 PM]
pois é, mas hoje não vejo pessoas ligando para nada do MIT[8:38]
tem uma Netflix usando reactjshenrique [8:39 PM]
95% ou mais de projetos js são MIT[8:39]
os relevantessebas5384 [8:39 PM]
porque é default[8:39]
hehe[8:39]
tipo[8:39]
o cara da npm init[8:39]
e vai que vaihenrique [8:39 PM]
não é default nãosebas5384 [8:39 PM]
hmm achei que era[8:40]
mesmo assim, é default na comunidade js[8:40]
e isso porque se conhece pouco da lisençahenrique [8:40 PM]
MBP-de-Henrique:~ henrique$ mkdir whatever MBP-de-Henrique:~ henrique$ npm init -y Wrote to /Users/henrique/package.json: { "name": "henrique", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }
sebas5384 [8:40 PM]
saqueihenrique [8:41 PM]
MIT só garante copyright, acho que não é o ideal para projetos que tem muitos contribuidoressebas5384 [8:41 PM]
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
[8:41]
ISC[8:41]
mesmo coisa[8:41]
a MERDA de tudo isso[8:41]
é que fomenta o OpenSource[8:41]
e não o software livrehenrique [8:42 PM]
burocracia da porrasebas5384 [8:42 PM]
liverdade e libertinagem é diferentehenrique [8:42 PM]
por isso os caras colocam MIT e um comentário de commit “whatever” assim como no reduxsebas5384 [8:42 PM]
liverdade precisa ter um cuidado, em quanto libertinagem é whatever you like[8:42]
haha[8:42]
então[8:42]
por isso[8:42]
porque não entende o custo disso[8:43]
a GPL foi criada[8:43]
para manter o software livre[8:43]
não só para fomentar o open source[8:43]
codigo aberto não implica que é livre[8:43]
e sempre vai ser[8:44]
por exemplo[8:44]
se vc pegar um codigo com licença MIT vc pode trocar para o que vc quiser[8:44]
até fechar a porra do codigo[8:45]
tudo baseado na licença do BSD[8:45]
ISC, MIT, Apache, etc...[8:45]
GPL é a única que garante que o código SEMPRE seja livre[8:45]
conhecimento é de propriedade públicahenrique [8:45 PM]
e isso é restringir acesso que disse mais cedosebas5384 [8:45 PM]
e eu gosto de garantir que isso seja sempre assimhenrique [8:45 PM]
MIT garante que vc pode inclusive fechar o código[8:45]
😛sebas5384 [8:46 PM]
que tipo de acesso?[8:46]
mas isso não é restringir acessohenrique [8:46 PM]
acesso a quem quer fazer código fechadosebas5384 [8:46 PM]
perfeito[8:46]
é isso mesmo que não gosto[8:46]
por isso gosto do SL[8:46]
rsrs[8:47]
se licenças como GPL não existirem hoje o opensource não seria nem conhecido[8:47]
eu sou contra a movimentos de libertinagem[8:48]
porque criam liverdade sem regras, que permitem que outro indivíduo tenha sua liberdade tambem[8:48]
essas regras são de dominio público[8:48]
não criadas com o termo “whatever"[8:49]
whatever não tem opiniãohenrique [8:49 PM]
sim, é meio anárquico e desapegadosebas5384 [8:49 PM]
:simple_smile:[8:50]
até a anarquia tem suas opniões[8:50]
auto-organização , etc...[8:50]
hehe[8:50]
GPL 3, ela deixa vc colocar o choko-redux por exemplo[8:50]
junto com software proprietário[8:50]
:simple_smile:[8:51]
digo, deixa ser distribuido[8:51]
e que o codigo seja GPL, não significa que vc é “obrigado” a abrir o código[8:51]
significa que se vc distribuir, ele precisa ser livre[8:51]
para sempre[8:51]
por exemplo[8:51]
no caso do google[8:52]
eles usam sl[8:52]
mas não ficam distribuindo o codigo[8:52]
mesma coisa se vc usase MIT[8:52]
a questão é a distribuição[8:52]
é a diferença de vc poder baixar o código fonte do sistema operacional que vc usa[8:53]
hehe[8:53]
eae?[8:53]
vamos GPL 3 ?[8:53]
hehe[8:53]
senão vou ter que convidar mad dog[8:53]
para tomar uma breja e te convencer[8:53]
hehehehenrique [8:53 PM]
eu entendo a questão, pra mim tantôfas, quero mesmo é ver o negócio fluir sem barreirassebas5384 [8:55 PM]
hehee[8:55]
então tem que ser GPL para isso ocorrer[8:55]
senão alguem pode chegar e botar barreiras 😉[8:55]
é uma garantiahenrique [8:55 PM]
to tomando uma homebrewed aquisebas5384 [8:55 PM]
GPL é garantia de que barreiras não serão colocadas[8:55]
opa[8:55]
😄[8:56]
eu acabei de abrir uma[8:56]
industrial[8:56]
rsrs[8:56]
mas é boa[8:56]
uma IPA
If we look at projects like react-redux
, redux-actions
or redux-promise
we can notice that their are using peerDependencies for the redux-*
dependencies.
I think we should follow this pattern because redux
it self for example must be a direct dependency of the project which is using or implementing these libs. It's more easy to know what dependencies the project has, but at the same time removes some kind of abstractions which could help legibility.
Should we move redux
, redux-actions
and redux-promise
to peerDependencies?
Middlewares using handlers should had the possibility of declaring something before the dispatch cycle.
For example:
const module = {
middleware: {
[HTTP_REQUEST]: store => {
const db = dbConnect()
return next => action => {
// Do something with the "db" connection.
return next(action)
}
}
}
}
https://github.com/choko-org/redux-boot/blob/master/src/processModules.js#L33-L42
Decide on naming, maybe we should refactor a little and rename this redux-boot, redux-bricks?
Need to update the handleAction to use the defaultState.
redux-utilities/redux-actions#127
Workaround for this bug is locking the peerDependencies to 0.13.0.
"redux-actions": "0.13.0",
Example with a simple reducer and an async middleware (Spotify API)
{ error: { status: 401, message: 'No token provided' } } 'Unauthorized'
✖ A side-effect of BOOT action modified the state using a middleware and reducer handler.
operator: equal
expected: 'Led Zeppelin'
actual: ''
at: Test.assert [as _assert] (/Users/arojunior/Dropbox/compartilhado/Github/redux-boot/build/test.js:1199:18)
I think this could establish a well known now code standard.
https://github.com/prettier/prettier
Write tests for:
combineReducers
configureStore
processModules
The GPL is an inappropriate license for a library, especially a JavaScript library. Anyone who uses redux-boot is required to release their code under a GPL-compatible license. This all but guarantees that pretty much nobody will adopt your library.
This requirement is explained clearly in the GPL FAQ:
if the two programs are combined so that they become effectively two parts of one program, then you can't treat them as two separate programs. So the GPL has to cover the whole thing.
Given that Redux uses the MIT license, you should stick with that. It's more permissive than the GPL and will encourage other developers to actually use your library.
Create Handlers API for middlewares, just like 'redux-actions' handleActions() but for middlewares.
Create a version of the lamernews using redux-boot.
Write tests for:
combineReducers
configureStore
processModules
We did a little search and Immutable.js showed the to be the fastest and more widely used.
See some benchmarking: https://github.com/mattbierner/js-hashtrie-benchmark
Need to improve this test case:
test('Use redux-actions with redux-promise to fire async and sync side-effect actions in middlewares', (assert) => {
const AFTER_BOOT = 'choko/core/test/AFTER_BOOT'
const AFTER_AFTER_BOOT = 'choko/core/test/AFTER_AFTER_BOOT'
let data = {
1: 'bar',
2: 'baz',
3: 'rock'
}
const someApi = {
get(id) {
return Promise.resolve({
name: data[id]
})
}
}
const afterBootAction = createAction(AFTER_BOOT, async (id) => {
const result = await someApi.get(id)
return result
})
const afterAfterBootAction = createAction(AFTER_AFTER_BOOT, async (id) => {
const result = await someApi.get(id)
return result
})
const initialState = {foo: 'bar'}
const reducer = (state = initialState, action) => {
switch (action.type) {
case AFTER_BOOT:
return {
...state,
foo: action.payload.name
}
case AFTER_AFTER_BOOT:
return {
...state,
foo: action.payload.name
}
default:
return state;
break;
}
}
const middleware = [
function middle9({getState, dispatch}) {
// Note the async keyword.
return next => (action) => {
console.log(action.type, 'ACTION')
const result = next(action)
if (action.type == AFTER_AFTER_BOOT) {
console.log(getState(), 'STATEEEE AFTER AFTER BOOT 9');
}
return result
}
},
function middleA({getState, dispatch}) {
// Note the async keyword.
return next => async (action) => {
const result = next(action)
if (action.type == AFTER_BOOT) {
// console.log(getState(), 'STATEEEE before A');
// const sideffectB = await dispatch(afterAfterBootAction(3))
console.log(getState(), 'STATEEEE AFTER BOOT');
}
return result
}
},
function middleB({getState, dispatch}) {
// Note the async keyword.
return next => async (action) => {
const result = next(action)
if (action.type == BOOT) {
const sideffectA = await dispatch(afterBootAction(2))
console.log(getState(), 'STATEEEE A');
const sideffectB = await dispatch(afterAfterBootAction(3))
console.log(getState(), 'STATEEEE AFTER AFTER BOOT B');
}
return result
}
},
function middleC({getState, dispatch}) {
// Note the async keyword.
return next => (action) => {
const result = next(action)
if (action.type == AFTER_AFTER_BOOT) {
console.log(getState(), 'STATEEEE AFTER AFTER BOOT C');
}
return result
}
}
]
const testModule = {
reducer,
middleware
}
const modules = [
testModule
]
const app = Choko(initialState, modules)
app.then(({action, store}) => {
assert.equal(
store.getState().foo,
'rock',
'Chainable async and sync side-effects were handled'
)
assert.end()
})
})
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.