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.

The redux way with ng2-redux

See original GitHub issue

Could we implement a very similar version of the redux integration: In the bootstrap

    let store = createStore(
        combineReducers(reducers),
        compose(
            applyMiddleware(apolloClient.middleware()),
            window.devToolsExtension ? window.devToolsExtension() : f => f
        )
    );

    let providers = [
        NgRedux,
        APOLLO_PROVIDERS,
        defaultApolloClient(apolloClient),
    ];

    enableProdMode();
    let ngComponentRef:ComponentRef = await bootstrap(App);
    let _ngRedux:NgRedux = ngComponentRef.injector.get(NgRedux);
    _ngRedux.provideStore(store);

In the component

@connect({
    mapStateToProps(state) {
         return {...};
    },
    mapQueryToProps() {
       return {...}
    }
})
@Component({...})
export class MyComponent {

}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
gsanscommented, Aug 13, 2016

I would say that these are the options I’ve seen being used in the Angular Community:

  1. original Redux; there’s a RxJS 5 middleware (redux-observable)
  2. 3rd party bindings: ng2-redux
  3. Observables: ngrx/store and co

Adoption is still slow so no clear winner.

1reaction
alexthewildecommented, Jan 20, 2017

For anyone still interested in integrating the Apollo client store with an existing Redux store, here’s a working example app I published.

If you inspect the store with Redux DevTools, you’ll see the apollo state alongside the ng2-redux store state.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jayphelps/ng2-redux: Angular 2 bindings for Redux - GitHub
Ng2Redux uses an approach to redux based on RxJS Observables to select and transform data on its way out of the store and...
Read more >
Getting Started with Redux & Angular 2 | Rangle.io
For this, we will be using a library called ng2-redux, which is available on npm via npm install ng2-redux . First, we need...
Read more >
angular-redux/ng2-redux - Gitter
Hi, wanted to understand how to handle a situation when a component has an input field that get's the data from an observable...
Read more >
Building a Redux Application with Angular 2 - Part 1
Redux centralizes the state into a single entity, granting developers access to the most recent state anywhere in the application.
Read more >
Angular + Redux — The lesson we've learned for you - Medium
Although I was impressed by Angular's two-way data binding and the ... @angular-redux (aka ng2-redux) uses Angular's features to help ...
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