Coder Social home page Coder Social logo

milankinen / culli Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 0.0 107 KB

[NOT MAINTAINED] Cycle Utility Libraries for clean, well-structured and concise code

License: MIT License

JavaScript 98.29% HTML 1.71%
cyclejs reactive-programming state-management virtual-dom

culli's People

Contributors

milankinen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

culli's Issues

s.subscribe is not a function

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.

Nested lists with RxJS 5.0

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

Add todomvc example

Every self-respecting library requires the classical todo-mvc app as an example πŸ˜„

Add ability to store local state inside components

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?

Make Store lenses serializable

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.

Update Store.select docs

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:

  • Add available selectors to API docs
  • Write at least a simple example using e.g. partial.lenses with @culli/store

Never ending loop when running `npm i`

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.

Compose store from multiple "sub-stores"

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.