Giter Club home page Giter Club logo

Comments (9)

supasate avatar supasate commented on May 25, 2024 1

Hi all, I've made it support Immutable.js already in the 4.0.0-beta.3 release.

Just import ConnectedRouter, routerMiddleware and connectRouter from connected-react-router/immutable.

See more details here.

from connected-react-router.

supasate avatar supasate commented on May 25, 2024

I never try with Immutable.js yet. Is there anything that can affect the result?

from connected-react-router.

ecozoic avatar ecozoic commented on May 25, 2024

I was playing around with Immutable.js this weekend so I decided to give this a try.

You can see an example of how this would work w/ Immutable in my fork: https://github.com/ecozoic/connected-react-router/pull/1/files

These changes assume your entire state object is an Immutable iterable (so if you use combineReducers that means you are using a library like redux-immutable). I've seen examples where the state object itself is mutable but all of its top level properties are immutable iterables. Implementation for something like that would be slightly different.

This is just a POC, to do something for real we would want this to be configurable somehow. Primary changes are in the ConnectedRouter where we read values from the store and in the connectRouter/routerReducer where we actually update state. Could maybe provide an "immutable" option on the router/middleware or more generally allow consumers to pass in some functions as props/arguments to customize behavior.

from connected-react-router.

supasate avatar supasate commented on May 25, 2024

Thanks @ecozoic. I understand it now. I may provide useImmutable option to make it simple to use. (If you would like to submit a PR, it is welcome!)

I'm not sure how often people use other ways to select value from the state object. So, I may provide an option to specify selector function in the future if there are several requests on this feature.

from connected-react-router.

nickwaelkens avatar nickwaelkens commented on May 25, 2024

I had made my own fork of this project supporting ImmutableJS, but it would be kind of stupid to make a separate PR when @ecozoic works wonders already! Great work.

I was wondering what the best API would be if you would support Immutable out of the box? One example is redux-form, eg it has 2 ways to import things;

import { Field } from 'redux-form'
import { Field } from 'redux-form/immutable'

It uses a factory function to create the correct type. Maybe the same principle can be used here?

from connected-react-router.

supasate avatar supasate commented on May 25, 2024

@nickwaelkens I like the way redux-form did. I might go that path.

from connected-react-router.

nickwaelkens avatar nickwaelkens commented on May 25, 2024

Great work @supasate. Will try this out soon but looks good!

from connected-react-router.

ecozoic avatar ecozoic commented on May 25, 2024

Yes thanks so much @supasate ! Adding this to my react-starter and it seems to be working great!

EDIT - here's a PR w/ changes to support it. super easy!
https://github.com/ecozoic/react-starter/pull/39/files

from connected-react-router.

supasate avatar supasate commented on May 25, 2024

@ecozoic Cool! Great to know it works for you!

from connected-react-router.

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.