Giter Site home page Giter Site logo

Comments (4)

eliperelman avatar eliperelman commented on May 24, 2024 1

Also of use is the pattern laid out in redux-boilerplate by using onEnter to emit a URL change action. Doesn't cover all use cases but maybe a good majority.

from prism.

tomkis avatar tomkis commented on May 24, 2024

Interesting, I was also thinking about such a feature earlier. @slorber was also thinking about something similar (slorber/scalable-frontend-with-elm-or-redux#2).

Anyway for your specific usecase, it does make sense to dispatch an action in componentWillReceiveProps when your router params change (it's pretty common actually in react-router world).

from prism.

jmarceli avatar jmarceli commented on May 24, 2024

Thanks for replies.
@tomkis1 Your solution works well in my case. Example below (for future reference):

class OrderPage extends React.Component {
  componentWillReceiveProps(nextProps) {
    if (this.props.params.id !== nextProps.params.id) {
      // this will be dispatched each time the route is changed from `orders/1` to `orders/2` 
      this.props.dispatch({ type: action.Load, orderId: nextProps.params.id });
    }
  }
  render() { ... }
}
export default view(({ model, dispatch, params }) => (
  <OrderPage dispatch={dispatch} model={model} params={params} />
));

@eliperelman onEnter is nice alternative but I'm afraid that in my case it would be hard to track down all "routing" buttons and add onEnter to all of them (high probability of runtime bugs).

Anyway @tomkis1 how do you feel about idea of "global" action prefixes. I know that they should not exists in perfectly fractal (Elm) world but for ensuring compatibility with standard react/redux libraries they might be useful.

from prism.

tomkis avatar tomkis commented on May 24, 2024

@jmarceli I think it's something we can totally consider adding as part of the framework. However, need to figure out proper API. So far having an option to configure "global actions" seems the most sane to me.

from prism.

Related Issues (20)

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.