milankinen / culli Goto Github PK
View Code? Open in Web Editor NEW[NOT MAINTAINED] Cycle Utility Libraries for clean, well-structured and concise code
License: MIT License
[NOT MAINTAINED] Cycle Utility Libraries for clean, well-structured and concise code
License: MIT License
Hi, I'm looking forward to try this library, but I'm getting this on the console:
bundle.js:291 Uncaught TypeError:
First I thought it was my fault, but then I try with the examples and I'm getting the same error.
Hi there,
Quick question, how would I go on about introducing initial state from within a child component instead of passing it directly in main?
With state like this
{ users: [ {id: ..., users: [ { id: ..., note: '' } ] } ] }
when I'm trying to do dynamic list in first component everything is ok, but in second component with state like this
{ id: ..., users: [ { id: ..., note: '' } ] }
nothing works with value.select('users')
.
When I'm trying to do
props.users.value.subscribe(...)
I got this error TypeError: this.source.run is not a function
Every self-respecting library requires the classical todo-mvc
app as an example π
Sometimes components might need to store "local state" for staging purposes and modify that "local state" before the staged changes are committed to the global state. @culli/store
should provide a way for such purposes.
I've thought the following API:
function main({Store}) {
const {dispatch, props} = model(Store.withLocal({propA: initialA, propB: initialB , ...}))
...
}
Which augments propA
, propB
etc.. named properties to the store and which can be modified by using the same reducer function as for "global props". However, those props or changes to them are not emitted outside from this component.
More complex example:
// Store = {item: <id>}
export default function AutoComplete({Store}) {
const {dispatch, props} = model(Store.withLocal({q: "", items: [], selIdx: -1}))
const vdom = view(props)
const actions = intent(vdom, props)
return {
DOM: combine(vdom),
Store: dispatch(actions)
}
function model({actions, value}) {
// value is now: Observable({item, q, items, selId})
const dispatch = actions.reduce(byType({
"SET_QUERY": (state, q) => ({...state, q}),
"SET_ITEMS": (state, items) => ({...state, items}),
"SET_IDX": (state, idx) => ({...state, selIdx: keepInRange(state.items, idx)})
"SET_SELECTED": (state, sel) => ({...state, item: sel})
}))
return {
dispatch,
props: {
query: value.select("q"),
items: value.select("items"),
idx: value.select("selIdx"),
item: value.select("item")
}
}
}
function view(props) {
...
}
function intent(vdom, props) {
const setQuery = vdom
.on(".q", "input")
.map(e => ({type: "SET_QUERY", payload: e.target.value}))
const setItems = changes(props.query.value)
.debounce(100)
.map(q => fetchItems(q))
.switch()
.map(items => ({type: "SET_ITEMS", payload: items}))
const setSelIdx = vdom
.on(".search", "keydown")
.filter(isNaviKey)
.map(e => ({type: "SET_IDX", payload: calcIdx(e)}))
// only these actions modify the global state
const setSelected = vdom
.on(".commit", "click")
.sample((idx, items) => items[idx], props.idx.value, props.items.value)
.map(item => ({type: "SET_SELECTED", payload: item}))
return O.mergeArray([
setQuery,
setItems,
setSelIdx,
setSelected
])
}
}
Any thoughts?
If we want to synchronize actions e.g. over WebSocket, the lenses focusing changes to specific state paths must be serializable. Now .select
uses only property and index lens and .mapChildren
uses only findBy({id})
so those lenses should be serializable.
In order to support serializations, the wholelenses.js
module must be re-written from @culli/store
.
Although Store's .select(selector)
has had a support for {get, set}
objects and van Laarhoven lenses out-of-the-box (in addition to property string) from the beginning, this feature has still remained undocumented.
We should:
partial.lenses
with @culli/store
On button click reducer getting called and state changing. But num is not updated in view
When trying to run install I am getting never ending loop:
Β± |master β| β npm i
> [email protected] postinstall /Users/dmitrizaitsev/Repos/culli
> npm run setup && npm run build
> [email protected] setup /Users/dmitrizaitsev/Repos/culli
> nb link && nb exec -- npm i && nb exec -- npm run update:bins
WARNING: Failed to find a Northbrook configuration file
> culli
has no dependencies to link
WARNING: Failed to find a Northbrook configuration file
β― culli - npm i
> [email protected] postinstall /Users/dmitrizaitsev/Repos/culli
> npm run setup && npm run build
> [email protected] setup /Users/dmitrizaitsev/Repos/culli
> nb link && nb exec -- npm i && nb exec -- npm run update:bins
WARNING: Failed to find a Northbrook configuration file
> culli
has no dependencies to link
WARNING: Failed to find a Northbrook configuration file
β― culli - npm i
^CβΈ¨βββββββββββββββββββΈ© β § normalizeTree: sill install loadCurrentTree
and so on.
Following the idea of CALMM Molecules
. However, not sure what are the real use cases for this feature and if there are any, could they be avoidable by structuring the app a bit differently.
TL;DR;
function view(props) {
const list = TodoList({...sources, Store: compose({filter: props.filter, items: props.items})})
...
}
Low prio, at least for now. Any thoughts folks?
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.