question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change update to reducers

See original GitHub issue

I used update because that’s how Elm calls it, but now that I am in the process of documenting HyperApp more thoroughly, I find myself explaining that update is an object composed of reducers, which begs the question, why then not just call it reducers?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jorgebucarancommented, Feb 17, 2017

https://github.com/hyperapp/hyperapp/commit/7a60a8f18163c31ec74c174c18337b7a31ae2dfb

I’ve changed it to reducers, but still back supporting update, which should be deprecated by 0.6.0 or later.

0reactions
jorgebucarancommented, Feb 15, 2017

I think vuex choice is acceptable, since it’s really obvious your’re mutating a value.

const store = new Vuex.Store({
  state: 1,
  mutations: {
    add (state) { state++ }
  }
})

However, in HyperApp, things are slightly different:

update: {
  add: model => model + 1
}

const newModel = actions.add(oldModel, data)
render(view(newModel))

We don’t mutate the model, but rather create a new one from the old one.


Now, in reality, hyperapp does mutate the model, because that was simpler to implement and maintain than this:

const render = model =>
    view(model, (action, model) =>
        patch(element, render(reduce(model, action))))
<small>From yo-yo-app.</small>

But now, that’s an implementation detail 😆

Read more comments on GitHub >

github_iconTop Results From Across the Web

Actions and reducers: updating state - Human Redux
The simplest possible way to update a view is just store.subscribe() and then in that function, call store.getState() and re-render. ... For our...
Read more >
Right way to update state in redux reducers - Stack Overflow
We're just running our new reducer over each post in the list, to return an updated array of posts. In this case, the...
Read more >
Redux Fundamentals, Part 3: State, Actions, and Reducers
The official Redux Fundamentals tutorial: learn how reducers update state in response to actions.
Read more >
An intro to Redux and how state is updated ... - freeCodeCamp
The only way to update a state inside a store is to dispatch an action and define a reducer function to perform tasks...
Read more >
Few Ways to Update a State Array in Redux Reducer - Medium
First, we will find the index of the item in the array using findIndex() . Then we make a copy of the todos...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found